Question
I need help with C programming: The code is below , I appreciate it. Modify the code from I have posted so that it uses
I need help with C programming: The code is below , I appreciate it.
Modify the code from I have posted so that it uses heap memory to store percentage grades in the range from 0 to 100 (inclusive). 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. Be sure to free the heap memory before the program ends. Please comment the code so I can understand the processes and functions.
Since I need to understant this, Please write out in plain English what the program needs to do and describe the steps in the process to solve the problem. Focus on a clear explanation of the process of solving the problem, not writing C.
Code:
#include
int main(void){ //declare an array called grade as integers int grade[MAX_GRADE_COUNT]; int i; //loop variable //declare an int for count int count = 0; char continueResponse; //for loop used since we do not know how many grades //loop starts at 0 but less than max grade count of 300 //increment i each time for(i = 0; i < MAX_GRADE_COUNT; i++){ //aak user to enter grade printf("Enter grade (0-100): "); //scan as an array using loop with number of index scanf("%d", &grade[i]); //count number of entries count++; //asks user if tehy want to continue enter grades printf("Continue entering grades? (Y/N): "); //scans their response with space in control c //if user enter y then the continues scanf(" %c", &continueResponse); if(continueResponse == 'N'||continueResponse == 'n'){ printf(" == End of Grade Entry == "); //gets out of for loop early break; } }//end of the for loop //print the grades output printf("Grades Entered are: "); //output loop is for loop using count of less than for(i = 0; i < count; i++){ //print with padded on the left by using 3 digits wide printf("%3d ", grade[i]); } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started