I got the smallest number from the set the user inputs (i did this a couple days ago and basically im lost) however i cannot figure out how to obtain the largest integer in the set any help would be appreciated![]()
Code:#include<stdio.h> #include<math.h> int main() { int count, N; double num, sum, average; double small; double large; sum = 0.0; average = 0.0; count = 0; printf("How many numbers are in your set?" ); scanf("%d",&N); printf("Enter %d number(s) and <Enter> after each> ", N); while (count < N) { scanf("%lf",&num); sum = sum + num; average = sum / (double) N; count++; } small = num; while (++count < N) { scanf("%lf",&num); if (small < num) small = num; } /* print the result */ printf("\nSmallest=%.2f", small); printf("\nlargest=%.2f", large); printf("\nAverage=%.2f", average); system("pause"); return (0); }



LinkBack URL
About LinkBacks



