Create a C program that will accept student name, prelim grade, midterm grade and final grade then compute and display for cumulative grade based on the formula: CG=15% of prelim + 30% midterm + 55% final. Your program should display the output based on the following sample run.
Sample Run:
Enter student name:
Prelim grade:
Midterm grade:
Final grade:
Cumulative grade:
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
int main(){
char name[20];
double prelimGrade,midtermGrade,finalGrade,cumulativeGrade;
printf("Enter student name: ");
gets(name);
printf("Prelim grade: ");
scanf("%lf",&prelimGrade);
printf("Midterm grade: ");
scanf("%lf",&midtermGrade);
printf("Final grade: ");
scanf("%lf",&finalGrade);
//compute and display for cumulative grade based on the formula: CG=15% of prelim + 30% midterm + 55% final.
cumulativeGrade=0.15*prelimGrade+0.3*midtermGrade+0.55*finalGrade;
printf("Cumulative grade: %.2f\n",cumulativeGrade);
getchar();
getchar();
return 0;
}
Comments
Leave a comment