{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture-04.1

# Lecture-04.1 - Week 4.1 CSE 1540.03 Solutions#1 Problems#1...

This preview shows pages 1–2. Sign up to view the full content.

CSE 1540.03 Week 4.1 January 23, 2012 Problems #1. Write a program to input a sequence of positive numbers and compute the average. #2. Write a program to input a sequence of numbers and compute the average. #3. Change #1 and #2 to find the largest number in the sequence. #4. Change the problems to input n followed by n numbers. #5. Write a program to compute x e - . Solutions #1. Write a program to input a sequence of positive real numbers and compute the average. program oneA implicit none integer count real sum, x sum = 0.0 count = 0 do print*, "Enter the next number (end with neg. num.)" read*, x if (x .lt. 0.0) exit sum = sum + x count = count + 1 end do print*, "Average = ", sum/count end test data: general case: 7.5 2 12.6 4.3 -1 boundary case #1: 2.5 -1 boundary case #2: -1 CSE 1540 Week 4.1 – January 23, 2012 page 1 of 2

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Stream processing paradigm Program reads a sequence of data items, each data item is processed and discarded before the next data item is read and processed. Program is independent of the size of the data to be processed.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

Lecture-04.1 - Week 4.1 CSE 1540.03 Solutions#1 Problems#1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online