condit.cpp 368 B

123456789101112131415
  1. // condit.cpp -- using the conditional operator
  2. #include <iostream>
  3. int main()
  4. {
  5. using namespace std;
  6. int a, b;
  7. cout << "Enter two integers: ";
  8. cin >> a >> b;
  9. cout << "The larger of " << a << " and " << b;
  10. int c = a > b ? a : b; // c = a if a > b, else c = b
  11. cout << " is " << c << endl;
  12. // cin.get();
  13. // cin.get();
  14. return 0;
  15. }