-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProg.cpp
More file actions
21 lines (18 loc) · 742 Bytes
/
Copy pathProg.cpp
File metadata and controls
21 lines (18 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Introducing the conditional operator ?: which takes 3 operands.
// Structure: A ? B : C
// Conditional Operator together with the operands form the conditional expression.
// 'A' represents a condition which is True or False.
// If 'A' is True then 'B' is replaced by the entire conditonal expression.
// If 'A' is False then 'C' is replaced by the entire conditional expression.
// So the conditional operator does not return values, but replaces operands with the whole expression.
#include <iostream>
using namespace std;
int main()
{
int grade;
cout << "Enter the grade : ";
cin >> grade;
cout << (grade >= 60 ? "Passed\n" : "Failed\n");
grade >=60 ? cout << "Passed\n" : cout << "Failed\n";
return 0;
}