In: Computer Science
You are using ONLY Programming Language C for this:
In this program you will calculate the average of x students’ grades (grades will be stored in an array). Here are some guidelines to follow to help you out:
1. In your program, be sure to ask the user for the number of students that are in the class. The number will help in declaring your array.
2. Use the function to scan the grades of the array. To say another way, we will populate the array with a function.
3. When done, you are going to use a printing function to make sure all grades are scanned correctly.
4. After that, you will call the “average” function. This function will receive two parameters: the array’s length and the array. Inside that function, you will calculate the average (use a loop for this) and you will return the average.
5. In main, you will have received this returned value and print it (IMPORTANT).
This Solution is for only 1 student, Although I have created the test cases so you go any number of test cases. #include<stdio.h> void main() { int t; //For Test Cases scanf("%d",&t); while(t--) { int mark[5], i; //Creating Marks in array float sum=0,avg; printf("Enter marks obtained in 5 subjects :"); for(i=0; i<5; i++) //Using Loop to enter marks { scanf("%d",&mark[i]); sum=sum+mark[i]; } avg=sum/5; //Average Formula printf("Your Grade is "); //Assuming Grades for students if(avg>80) { printf("A"); } else if(avg>60 && avg<=80) { printf("B"); } else if(avg>40 && avg<=60) { printf("C"); } else { printf("D"); } } }