-
What is the output of the following program?
#include
using namespace std;
int main()
{
int a = -10;
unsigned int b = 20;
if(a > b)
{
cout << "a is greater";
}
else
{
cout << "b is greater";
}
return 0;
}
-
- 10
- 20
- a is greater
- b is greater
- None of these
Correct Option: C
a is promoted to unsigned int on comparison. On conversion a has all bits set, making it the bigger one.