Conditional Operator

#include <iostream.h>
int main()
 {
 int x, y;
 cout << "Enter two integers: ";
 cin >> x >> y;
 cout << x << ( x == y ? " is" : " is not" )
 << " equal to " << y << endl;
return 0;
}

OUTPUT:
       Enter two integers: 7 5
       7 is not equal to 5
       Enter two integers: 8 8
       8 is equal to 8


No comments:

Post a Comment