Friday, 14 December 2012
//C program to calculate GPA
#include<stdio.h>
#include<conio.h>
main()
{
char a[8];float b;int i;int n[8];char c;
start:
clrscr();
printf("\nCopyright(c)2012 Winston\n\n\nEnter the Grades in this Order.\neg:cdeacaed\nCY2111 Chemistry");
printf("\nGE2111 EG ");
printf("\nGE2112 FOCP ");
printf("\nGE2115 CP ");
printf("\nGE2116 EP ");
printf("\nHS2111 English ");
printf("\nMA2111 Maths ");
printf("\nPH2111 Physics ");
printf("\nEnter Grades:");
scanf("%s",a);
for(i=0;i<8;i++) /*Checking each character*/
{
if(a[i]=='s') n[i]=10;
if(a[i]=='a') n[i]=9;
if(a[i]=='b') n[i]=8;
if(a[i]=='c') n[i]=7;
if(a[i]=='d') n[i]=6;
if(a[i]=='e') n[i]=5;
}
//The grades points are multiplied by credits and summed up
b=n[0]*3+n[1]*5+n[2]*3+n[3]*2+n[4]*2+n[5]*4+n[6]*4+n[7]*3;
printf("GPA %0.2f",b/26); /*Dividing by total number of credits,%0.2f for two decimal points */
printf("\nPress c to continue or any key to exit");
c=getche();
if(c=='c') goto start;
getch();
}
I did this during the time of my first semester results
Very useful for bulk calculation of GPA.
Download the source code and the executable here.GPA-calculator
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment