Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4) Write a C program that calculates the average scores of a class of total 9 students. The scores of the students are: 82, 65,

4) Write a C program that calculates the average scores of a class of total 9 students. The scores of the students are: 82, 65, 98, 57, 90, 80, 86, 79 and 92. Also computes the statistics on number of A, B, C, D and F students, use the range given in syllabus.

So far this is what I have:

/* Write a C program that calculates the average scores of a class of total 9 students. The scores of the students are: 82, 65, 98, 57, 90, 80, 86, 79 and 92. Also computes the statistics on number of A, B, C, D and F students. */

# include # include

int main(void) { unsigned int counter; //number of grades entered int grade; //grade score int total; //sum of grades

float average; //number with decimal point for avg

//initilization phase total = 0; //total counter = 0; //loop counter

//processing phase //get first grade printf("%s", "Enter grade, -1 to end: "); //prompt input scanf("%d", &grade); //read grade

//loop while sentinel value not yet entered while (grade != -1) { total = total + grade; //add grade to total counter = counter + 1; //increment counter

//get next grade printf("%s", "Enter grade, -1 to end: "); //prompt input scanf("%d", &grade); //read next grade } //termination phase //if at least one grade is entered if (counter != 0) { //calculate avg of all grades average = (float)total/counter;

//display avg with two digits of precision printf("Class average is %.2f ", average); } //otherwise if no grades are entered else { puts("No grades were entered."); } } //end program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

What do the terms SIMPLE and SCREAM stand for?

Answered: 1 week ago

Question

Draw a picture consisting parts of monocot leaf

Answered: 1 week ago