Program
#include <stdio.h> int main() { int phy, chem, bio, math, comp; float per; printf("**********************************************************"); printf("\n**********************************************************"); printf("\n**WAP to find total percentage & grade of a student in C**"); printf("\n** Created by Sheetal Garg **"); printf("\n** Assistant Professor **"); printf("\n** Phone No:9467863365 **"); printf("\n**********************************************************"); printf("\n**********************************************************"); /* Input marks of five subjects from user */ printf("\nEnter five subjects marks: "); scanf("%d%d%d%d%d", &phy, &chem, &bio, &math, &comp); /* Calculate percentage */ per = (phy + chem + bio + math + comp) / 5.0; printf("Percentage = %.2f\n", per); /* Find grade according to the percentage */ if (per >= 90) { printf("Grade A"); } else if (per >= 80) { printf("Grade B"); } else if (per >= 70) { printf("Grade C"); } else if (per >= 60) { printf("Grade D"); } else if (per >= 40) { printf("Grade E"); } else { printf("Grade F"); } return 0; }
Output 1
********************************************************** ********************************************************** **WAP to find total percentage & grade of a student in C** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** Enter five subjects marks: 91 91 94 92 92 Percentage = 92.00 Grade A
Output 2
********************************************************** ********************************************************** **WAP to find total percentage & grade of a student in C** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** Enter five subjects marks: 81 81 84 82 82 Percentage = 82.00 Grade B
Output 3
********************************************************** ********************************************************** **WAP to find total percentage & grade of a student in C** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** Enter five subjects marks: 71 71 74 72 72 Percentage = 72.00 Grade C
Output 4
********************************************************** ********************************************************** **WAP to find total percentage & grade of a student in C** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** Enter five subjects marks: 60 67 78 70 60 Percentage = 67.00 Grade D
Output 5
********************************************************** ********************************************************** **WAP to find total percentage & grade of a student in C** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** Enter five subjects marks: 40 40 40 40 40 Percentage = 40.00 Grade E
Output 6
********************************************************** ********************************************************** **WAP to find total percentage & grade of a student in C** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ********************************************************** ********************************************************** Enter five subjects marks: 30 30 30 30 30 Percentage = 30.00 Grade F