Monday, August 17, 2009

c++: printf("%d", main||c);

main()
{
int c = 5;
printf("%d", main||c);
}
A) none of the above
B) 0
C) 5
D) 1
Explanation: if we use main|c then error, illegal use of pointer

D.
Here || operator is used which returns 1 when first operand is not zero without evaluating second operand so it returns 1 because the address of main function is not zero.

No comments:

Post a Comment