-
Notifications
You must be signed in to change notification settings - Fork 0
/
Else_ifProgramming.cpp
66 lines (66 loc) · 1.29 KB
/
Else_ifProgramming.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
#include <bits/stdc++.h>
using namespace std;
// A school has following rules for grading system:
// a. Below 25 - F
// b. 25 to 44 - E
// c. 45 to 49 - D
// d. 50 to 59 - C
// e. 60 to 79 - B
// f. 80 to 100 - A
// Ask user to enter marks and print the corresponding grade.
// if we use multiple if conditions all the if conditions will be checked
// and if we use (else if) if one condition is true after that it will not go to next line
int main()
{
int marks;
cin >> marks;
// if (marks < 25)
// {
// cout << "F";
// }
// if (marks >= 25 && marks <= 44)
// {
// cout << "E";
// }
// if (marks >= 45 && marks <= 49)
// {
// cout << "D";
// }
// if (marks >= 50 && marks <= 59)
// {
// cout << "C";
// }
// if (marks >= 60 && marks <= 79)
// {
// cout << "B";
// }
// if (marks >= 80 && marks <= 100)
// {
// cout << "A";
// }
if (marks < 25)
{
cout << "F";
}
else if (marks <= 44)
{
cout << "E";
}
else if (marks <= 49)
{
cout << "D";
}
else if (marks <= 59)
{
cout << "C";
}
else if (marks <= 79)
{
cout << "B";
}
else if (marks <= 100)
{
cout << "A";
}
return 0;
}