BlueX

[C++]: Conditional operator

Aug 2nd, 2012
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. int main(){
  6.  
  7.     int a = 5;
  8.     int b = 6;
  9.     string result;
  10.  
  11.     b==a ? (result = "YES") : (result = "NO");
  12.     cout << "B it's equal a A? " << result << endl;
  13.     b<a ? (result = "YES") : (result = "NO");
  14.     cout << "B it's less than A? " << result << endl;
  15.     b>a ? (result = "YES") : (result = "NO");
  16.     cout << "B it's biger than A? " << result << endl;
  17.     system("PAUSE");
  18.     return 0;
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment