Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Directions: Modify the grade book code so that it uses custom functions to add grades to the array, print the grades entered, calculate the average

Directions: Modify the grade book code so that it uses custom functions to add grades to the array, print the grades entered, calculate the average grade (arithmetic mean, not letter grade), and report the highest and lowest grade entered. This version of the program does not need to use heap memory, though you are welcome to do so. The program should allow the user to indicate when he or she is done entering grades (since the user may not have grades to fill the whole array). When the user is done entering grades, the program should print out the grades entered by the user. The program should also display the average grade, highest grade, and lowest grade.

Here is the current code:

#include #include #include

int main() { #define INT_MAX 100; #define INT_MIN 34;

char choice; const int SIZE=5; int percentArray[5]; int percentage; int count=0,i; double total=0; double avg=0; int low,high;

//Set MAX TO low low=INT_MAX; //Set MIN TO high high=INT_MIN;

for(count=0; count { //for loop to read the grades till array size printf("-------------------Enter percentage--------------- Add marks(a) Quit(q) "); scanf("%c",&choice); if(choice == 'a') { //if user choice is a, then read the grade printf( "Enter grade:"); scanf("%d", &percentage); percentArray[count] = percentage; //add the grade to array

//sum of percentArray values total+=percentArray[count];

//update low if(percentArray[count] low=percentArray[count];

//update high if(percentArray[count]>high) high=percentArray[count]; count++;

} if(choice == 'q') //if choice is q, exit the loop { break; } //clear buffer fflush(stdin); } printf("Grades are: "); for(i=0; i { //print grades printf("%d ", percentArray[i]); }

//print average ,low and high vlaues to console printf(" Average : %5.2f ",total/count); printf("Lower Grade : %5d ",low); printf("Higher Grade : %5d ",high);

getch(); return 0;

}

My question is, how can I modify the current code without using #include , as using this is not standard.

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, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

Discuss the key ambient conditions and their effects on customers.

Answered: 1 week ago