THIS PROGRAM WILL CALCULATE THE GPA FOR 5 SUBJECTS
#include<stdio.h>
#define SIZE 5
float gpa(float n );
char grade(float n );
char sign(float n );
int main()
{
int a[SIZE];
int sum=0,i,k;
float average,mul=0;
printf("PLEASE ENTER THE
NUMBERS OF 5 SUBJECTS\n");
for(i=0;i<=SIZE-1;i++)
scanf("%d",&a[i]);
printf("NAME :-
\"ADEEL
TALAT\"");printf("\n\nREGISTRATION NO
:-
\"DDP-SP14-BCS-A-041\"");
printf("\n\n%s%15s%15s%15s","C.H","MARKS","GRADE","GPA");
for(k=0;k<=SIZE-1;k++)
{
printf("\n3%13d
%13c%c%18.1f",a[k],grade(a[k]),sign(a[k]),gpa(a[k]));
sum+=a[k];
mul+=3*gpa(a[k]);
}
average=sum/SIZE;
printf("\n\n TOTAL
MARKS = %d",sum);
printf("\n AVERAGE
= %.2f",average);
printf("\n TOTAL GPA
= %.1f",mul/15);
printf("\n TOTAL GRADE =
%.c\n\n\n",grade(average));
return 0;
}
float gpa(float n )
{
if(n>=90)
{ return 4.0
;}
else
if(n<90 && n>=85)
{return 3.7
;}
else
if(n<85 && n>=80)
{return
3.3 ;}
else
if(n<80 && n>=75)
{return 2.0 ;}
else
if(n<75 && n>=70)
{return
2.7 ;}
else
if(n<70 && n>=65)
{return 2.3 ;}
else
if(n<65 && n>=60)
{return
2.0 ;}
else
if(n<60 && n>=55)
{return
1.7 ;}
else
if(n<55 && n>=50)
{return
1.3 ;}
else if
(n<50)
{return 0.0 ;}
}
char grade(float n )
{
if(n>=90)
{ return 'A'
;}
else
if(n<90 && n>=85)
{return 'A'
;}
else
if(n<85 && n>=80)
{return
'B' ;}
else
if(n<80 && n>=75)
{return 'B' ;}
else
if(n<75 && n>=70)
{return
'B' ;}
else
if(n<70 && n>=65)
{return
'C' ;}
else
if(n<65 && n>=60)
{return
'C' ;}
else
if(n<60 && n>=55)
{return
'C' ;}
else
if(n<55 && n>=50)
{return 'D' ;}
else if (n<50)
{return 'F' ;}
}
char sign(float n )
{
if(n>=90)
{ return' ';}
else
if(n<90 && n>=85)
{return '-'
;}
else
if(n<85 && n>=80)
{return
'+' ;}
else
if(n<80 && n>=75)
{return' ' ;}
else
if(n<75 && n>=70)
{return
'-' ;}
else
if(n<70 && n>=65)
{return
'+' ;}
else
if(n<65 && n>=60)
{return ' ' ;}
else
if(n<60 && n>=55)
{return
'-' ;}
else
if(n<55 && n>=50)
{return
' ';}
else if
(n<50)
{return ' ';}
}
No comments:
Post a Comment