Problem Statement
Calculating SGPA of a semester
#include<stdio.h>
int main()
{
float sum,sgpa,tempmin,tempmax,mark;
char b;
int sub,i;
tempmin=tempmax=0;
printf("enter the grades \n");
printf("enter x for ex \np for pass \na for a\nb for b\nc for c\nd for d\np for pass\n any other for fail\n");
printf("subject codes and resp. credits are\n");
printf("1 for maths credit=4\n");
printf("2 for chem credit=4\n");
printf("3 for pds credit=4\n");
printf("4 for mech credit=4\n");
printf("5 for pds lab credit=2\n");
printf("6 for engg. drawing credit=3\n");
printf("7 for chem lab credit=2\n");
for(i=1;i<11;i++)
{
sum=0.0;
for(sub=1;sub<8;sub++)
{
printf("enter the grade in subject %d of student %d\n",sub,i);
b=getchar();
getchar(); /* dummy getchar to eat enter */
switch (b)
{
case 'x':
mark=10;
break;
case 'a':
mark=9;
break;
case 'b':
mark=8;
break;
case 'c':
mark=7;
break;
case 'd':
mark=6;
break;
case 'p':
mark=5;
break;
default:
mark=0;
break;
}
if(sub<=4)
{
sum=sum+mark*4;
}
else if(sub==5||sub==7)
{
sum=sum+mark*2;
}
else
{
sum=sum+mark*3;
}
}
sgpa=sum/23.0;
printf("the sgpa is %f \n",sgpa);
if(sgpa>tempmax)
{
tempmax=sgpa;
}
if(sgpa<tempmin)
{
tempmin=sgpa;
}
}
printf("the maximum and minimum sgpa is %f ,%f resp.\n",tempmax,tempmin);
return 0;
}
Calculating SGPA of a semester
#include<stdio.h>
int main()
{
float sum,sgpa,tempmin,tempmax,mark;
char b;
int sub,i;
tempmin=tempmax=0;
printf("enter the grades \n");
printf("enter x for ex \np for pass \na for a\nb for b\nc for c\nd for d\np for pass\n any other for fail\n");
printf("subject codes and resp. credits are\n");
printf("1 for maths credit=4\n");
printf("2 for chem credit=4\n");
printf("3 for pds credit=4\n");
printf("4 for mech credit=4\n");
printf("5 for pds lab credit=2\n");
printf("6 for engg. drawing credit=3\n");
printf("7 for chem lab credit=2\n");
for(i=1;i<11;i++)
{
sum=0.0;
for(sub=1;sub<8;sub++)
{
printf("enter the grade in subject %d of student %d\n",sub,i);
b=getchar();
getchar(); /* dummy getchar to eat enter */
switch (b)
{
case 'x':
mark=10;
break;
case 'a':
mark=9;
break;
case 'b':
mark=8;
break;
case 'c':
mark=7;
break;
case 'd':
mark=6;
break;
case 'p':
mark=5;
break;
default:
mark=0;
break;
}
if(sub<=4)
{
sum=sum+mark*4;
}
else if(sub==5||sub==7)
{
sum=sum+mark*2;
}
else
{
sum=sum+mark*3;
}
}
sgpa=sum/23.0;
printf("the sgpa is %f \n",sgpa);
if(sgpa>tempmax)
{
tempmax=sgpa;
}
if(sgpa<tempmin)
{
tempmin=sgpa;
}
}
printf("the maximum and minimum sgpa is %f ,%f resp.\n",tempmax,tempmin);
return 0;
}
No comments:
Post a Comment