-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4th.cpp
More file actions
37 lines (29 loc) · 878 Bytes
/
4th.cpp
File metadata and controls
37 lines (29 loc) · 878 Bytes
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
// Program to calculate the grade of a student after the input of marks.
#include <iostream>
using namespace std;
int main() {
float totalMarks, obtainedMarks, percent;
char grade;
string name;
cout << "Enter Students Name: ";
cin >> name;
cout << "Enter total marks: ";
cin >> totalMarks;
cout << "Enter marks obtained: ";
cin >> obtainedMarks;
// Calculating percentage
percent = (obtainedMarks / totalMarks) * 100;
// Grade based on percentage
if (percent >= 90) {
grade = 'A';
} else if (percent >= 70) {
grade = 'B';
} else if (percent >= 50) {
grade = 'C';
} else {
grade = 'F';
}
cout << "Percentage: " << percent << "%" << endl;
cout << "Grade Obtained by " << name << " " << "is " << grade << endl;
return 0;
}