AIM:
Write a C program to develop a menu-driven Student Result Management System. The program should accept marks of students in multiple subjects, calculate total and percentage, determine pass/fail status and grade using decision-making statements, and display the result. Use functions for different operations and appropriate loops for repeated processing. Implement a menu using switch-case and provide an option to terminate the program.
Code:
#include <stdio.h>
void result()
{
int m[5], i, total = 0;
float per;
printf("Enter marks of 5 subjects: ");
for(i = 0; i < 5; i++) {
scanf("%d", &m[i]);
total += m[i];
}
per = total / 5.0;
printf("Total = %d\nPercentage = %.2f\n", total, per);
if(per >= 90)
printf("Grade: A+\n");
else if(per >= 75)
printf("Grade: A\n");
else if(per >= 60)
printf("Grade: B\n");
else if(per >= 40)
printf("Grade: C\n");
else
printf("Result: Fail\n");
}
int main()
{
int ch;
do {
printf("\n1. Enter Result\n2. Exit\nChoice: ");
scanf("%d", &ch);
switch(ch) {
case 1: result(); break;
case 2: printf("Exit"); break;
default: printf("Invalid Choice");
}
} while(ch != 2);
return 0;
}
Output :
No comments:
Post a Comment