-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrades_using_function.cpp
68 lines (67 loc) · 1.29 KB
/
grades_using_function.cpp
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
57
58
59
60
61
62
63
64
65
66
67
68
#include<iostream>
using namespace std;
void calculateGrade(int mark, char& grade)
{
if (mark >= 80)
{
if (grade == 'a' || grade == 'A')
cout << "The Grade is A" << endl;
else
{
cout << "Invalid Grade Enter " << endl;
cout << "The Correct Grade is A" << endl;
}
}
else if (mark < 80 && mark >= 65)
{
if (grade == 'b' || grade == 'B')
cout << "The Grade is B" << endl;
else
{
cout << "Invalid Grade Enter " << endl;
cout << "The Correct Grade is B" << endl;
}
}
else if (mark < 65 && mark >= 50)
{
if (grade == 'c' || grade == 'C')
cout << "The Grade is C" << endl;
else
{
cout << "Invalid Grade Enter " << endl;
cout << "The Correct Grade is C" << endl;
}
}
else if (mark < 50)
{
if (grade == 'f' || grade == 'F')
cout << "The Grade is F" << endl;
else
{
cout << "Invalid Grade Enter " << endl;
cout << "The Correct Grade is F " << endl;
}
}
}
int main()
{
int mark;
char grade;
for (int i = 0; i < 100; i++)
{
cout << "Enter the marks : ";
cin >> mark;
cout << "Enter the Grade : ";
cin >> grade;
if (mark == -1)
{
cout << "User Enter -1 so the Loop breaks";
break;
}
else if (mark >= 0)
{
calculateGrade(mark, grade);
}
}
return 0;
}