/* Program: Lab 6 Author: Peter Ng Class: CSCI 110 Date: 10/02/03 Description:Program to calculate average and count numbers within certain ranges I certify that: - All code used in my program is either my original work or was modified by me from the source code published in the text of this course or provided by my instructor. - I have not used code obtained from another student, or any other unauthorized source, either modified or unmodified. - I have not discussed or shared coding details of this program with anyone other than my instructor or MT. SAC tutors. I understand that I may discuss the concepts/ideas of this program with other students as long as we do not get down to the coding details. */ #include int main() { double average, num [9]= {73.3, 49.0, 83.4, 58.0, 65.1, 60.0, 95.5, 80.3, 10.5}; int counter, greater, less, x; x = 9; /* --------------------------Greater / Less--------------------------*/ counter = 0; greater = 0; less = 0; while (counter < x) { if (num [counter] > 75.0) greater = greater + 1; if (num [counter] < 50.0) less = less + 1; counter = counter + 1; } /* --------------------------average --------------------------*/ counter = 0; average = 0; while (counter < x) { average = average + num [counter]; counter = counter + 1; } average = average / x; /* ---------------------------Output----------------------------*/ printf("\nThe Numbers in the list are:\n "); counter = 0; while (counter < x) { printf("%6.1lf",num [counter]); counter = counter + 1; } printf("\nThe average is: %5.1lf ", average); printf("\nIn the list, \nthere are %4d numbers that are less than 50.0,", less); printf("\nthere are %4d numbers that are greater than 75.0", greater); printf("\nProgram is written by Peter Ng. \n"); return 0; }