forked from pezy/CppPrimer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex4_22.cpp
30 lines (27 loc) · 794 Bytes
/
ex4_22.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
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
unsigned grade;
while (cin >> grade) {
// first version(only use conditional operators)
cout << ((grade > 90) ? "high pass" : (grade < 60)
? "fail"
: (grade < 75) ? "low pass"
: "pass");
cout << endl;
// second version(only use if statements)
if (grade > 90)
cout << "high pass";
else if (grade < 60)
cout << "fail";
else if (grade < 75)
cout << "low pass";
else
cout << "pass";
cout << endl;
}
return 0;
}