Write a code in C language to Calculate average CGPA with grade and score
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
void calculateCGPA();
int main()
{
system("cls");
calculateCGPA();
}
void calculateCGPA()
{
int l;
printf("-------------- CGPA Calculating -----------------\n\n\n");
printf("How many semester results do you want input? :");
scanf("%d",&l);
printf("\n\n\n");
float *semrs = new float [l];
int i;
for (i = 0; i < l; i++)
{
printf(" Enter Semester %d Result(GPA): " , i+1);
scanf("%f", &semrs[i]);
printf("\n\n");
}
float semtot = 0;
for (int j = 0; j < l; j++)
{
semtot = semtot + semrs[j];
}
printf("******** Your CGPA is %f **********\n", (float)(semtot / l));
}
Comments
Leave a comment