c

******How can this program give me correct results in a tabular form******

include <stdio.h>

char grade(int score)
{
if (score >= 0 && score <= 100)
{
if (score > 69 && score <= 100)
{
printf("A\n");
}
else if(score > 59 )
{
printf("B\n");
}
else if(score > 49)
{
printf("C\n");
}
else if(score > 39)
{
printf("D\n");
}
else if(score >= 0)
{
printf("F\n");
}
}
else
{
printf("Invalid entry\n");
}
return 0;

}
int main ()
{
int comp101,comp102,comp103,comp104,comp105,comp106;
int i,mark[6];
float score;
int mean =0;

printf("Enter the mark\n");

printf("SUBJECT\t\tGRADE\n");
printf("comp101=",mark[0]);scanf("%d",&mark[0]);
printf("%c\n",grade(mark[0]));
printf("comp102=");scanf("%d",&mark[1]);
printf("%c\n",grade(mark[1]));
printf("comp103=");scanf("%d",&mark[2]);
printf("%c\n",grade(mark[2]));
printf("comp104=");scanf("%d",&mark[3]);
printf("%c\n",grade(mark[3]));
printf("comp105=");scanf("%d",&mark[4]);
printf("%c\n",grade(mark[4]));
printf("comp106=");scanf("%d",&mark[5]);
printf("%c\n",grade(mark[5]));
for(i=0;i<6;i++)
{
mean +=mark[i];
}
mean =mean/6;
printf("Mean mark/grade =%d\t",mean);
printf("%c\n",grade(mean));

return 0;
}

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories