c - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.


JoashJoash KenyaPosts: 2Member

******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.