forked from dimpeshmalviya/C-Language-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.c
More file actions
56 lines (47 loc) · 1.37 KB
/
report.c
File metadata and controls
56 lines (47 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <string.h>
// Structure to store student details
struct Student {
char name[50];
int roll;
float marks[5];
float average;
char grade;
};
// Function to calculate grade
char calculateGrade(float avg) {
if (avg >= 90) return 'A';
else if (avg >= 75) return 'B';
else if (avg >= 60) return 'C';
else if (avg >= 40) return 'D';
else return 'F';
}
int main() {
struct Student students[50];
int n, i, j;
printf("Enter number of students: ");
scanf("%d", &n);
for (i = 0; i < n; i++) {
printf("\nEnter details for student %d\n", i + 1);
printf("Name: ");
scanf("%s", students[i].name);
printf("Roll No: ");
scanf("%d", &students[i].roll);
float sum = 0;
for (j = 0; j < 5; j++) {
printf("Enter marks of subject %d: ", j + 1);
scanf("%f", &students[i].marks[j]);
sum += students[i].marks[j];
}
students[i].average = sum / 5.0;
students[i].grade = calculateGrade(students[i].average);
}
printf("\n--- Student Report ---\n");
for (i = 0; i < n; i++) {
printf("\nName: %s", students[i].name);
printf("\nRoll No: %d", students[i].roll);
printf("\nAverage Marks: %.2f", students[i].average);
printf("\nGrade: %c\n", students[i].grade);
}
return 0;
}