-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01problemcorrection.c
More file actions
52 lines (44 loc) · 1.24 KB
/
01problemcorrection.c
File metadata and controls
52 lines (44 loc) · 1.24 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
#include <stdio.h>
int main()
{
int marks1, marks2, marks3;
float average;
// Input marks
printf("Enter marks1:\n");
scanf("%d", &marks1);
printf("Enter marks2:\n");
scanf("%d", &marks2);
printf("Enter marks3:\n");
scanf("%d", &marks3);
// Calculate average
average = (marks1 + marks2 + marks3) / 3.0; // Use 3.0 for floating-point division
// Print average
printf("The average is %.2f\n", average); // Use %.2f for floating-point output
// Determine and print grade
if (average >= 33 && average < 55)
{
printf("Congratulations! You have passed.\n");
printf("Your grade is D\n");
}
else if (average >= 55 && average < 60)
{
printf("Congratulations! You have passed.\n");
printf("Your grade is C\n");
}
else if (average >= 60 && average < 90)
{
printf("Congratulations! You have passed.\n");
printf("Your grade is B\n");
}
else if (average >= 90 && average <= 100)
{
printf("Congratulations! You have passed.\n");
printf("Your grade is A\n");
}
else if (average < 33)
{
printf("Unfortunately! You have failed.\n");
printf("Your grade is E\n");
}
return 0;
}