Lecture-04.1 - Week 4.1 CSE 1540.03 January 23, 2012...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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.
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/13/2012 for the course CSE 1540 taught by Professor Hofbauer during the Winter '12 term at York University.

Page1 / 2

Lecture-04.1 - Week 4.1 CSE 1540.03 January 23, 2012...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online