Name this file gradecpp Write a program that calculates the
Name this file grade.cpp Write a program that calculates the total grade for N classroom exercises as a percentage. The user should input the value for N followed by each of the N scores and totals. Calculate the overall percentage (sum of the total points earned divided by the total points possible) and output it as a percentage. Sample input and output is shown below. How many exercises to input? 3 Score received for exercise 1: 10 Total points possible for exercise 1: 10 Score received for exercise 2: 7 Total points possible for exercise 2: 12 Score received for exercise 3: 5 Total points possible for exercise 3: 8 Your total is 22 out of 30, or 73.33%.
Solution
#include <stdio.h>
#include<conio.h>
void main()
{
int i,a,p[50],q[50],x=0,y=0;
float k;
clrscr();
printf(\"Enter the number of Exercise \");
scanf(\"%d\",&a);
for(i=1;i<=a;i++)
{
printf(\"Enter score receive of Exercise %d :\",i);
scanf(\"%d\",&p[i]);
printf(\"Enter total marks of Exercise %d :\",i);
scanf(\"%d\",&q[i]);
}
for(i=1;i<=a;i++)
{
x=x+p[i];
y=y+q[i];
}
k=(x*100)/y;
printf(\"Total marks obtain= %d\",x);
printf(\"Total marks of all Exercises are= %d\",y);
printf(\"Total percentage is %d\",k);
getch();
}
try this this code works on my c compiler try this , Thankyou
