Conditional operator: ?

This example reads in a grade and prints pass or fail.

1
2
3
4
5
6
7
8
9
10
11
// Pass fail
#include <iostream>
using namespace std;
int main() { 
  int grade;
  cout<<"Enter your grade:";
  cin>>grade;
  (grade<65)? cout<<"fail\n": cout<<"pass\n";
  system("pause");
  return 0;
} // main
CODE
Enter your grade: 72
pass
Press any key to continue . . .

NEXT: Tests if a month is valid