sol4 - 4 ' - #include <stdio.h> 1. /* This program...

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

View Full Document Right Arrow Icon
'סמ ליגרת-תונכת סרוק 4 ןורתפל אמגוד 1 תוקיטסיטטס בושיח . #include <stdio.h> /* This program gets a sequence of non-negative input numbers, until a negative number is encountered. Then it stops and calculates the following statistics: - the minimum - the maximum - the sum - the average */ int main() { double num, max = -1, min = -1, // min/max initialized as invalid values sum = 0, avg; int count = 0; // get first input printf( "Please enter number: " ); scanf( "%lf" ,&num); if (num > 0) { min = num; max = num; } else { printf( "No numbers to calculate statistics on\n" ); return 0; } while (num > 0) { count++; sum+=num; // update minimum and maximum if (min > num) min=num; if (max < num) max=num; // get next number printf( "Please enter number: " ); scanf( "%lf" ,&num); } avg = sum/count; printf( "max=%f, min=%f, sum=%f, avg=%f\n" ,max,min,sum,avg); return 0; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 . תויתוא שלושמ #include <stdio.h> /* This program receives as input the number of rows. It prints a letter pyramid with the specified number
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

sol4 - 4 ' - #include &lt;stdio.h&gt; 1. /* This program...

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

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