What is the output of this C code?
int main()
{
if (7 & 8)
printf(“Honesty”);
if ((~7 & 0x000f) == 8)
printf(“is the best policy\n”);
}
A. Honesty is the best policy
B .Honesty
C. is the best policy
D.No output
What is the output of this C code?
int main()
{
if (7 & 8)
printf(“Honesty”);
if ((~7 & 0x000f) == 8)
printf(“is the best policy\n”);
}
A. Honesty is the best policy
B .Honesty
C. is the best policy
D.No output
It is option c
~7 will give us 8 and after bitwise and with 15 (in hex) it results in value 8.
As 8 == 8 therefore, output must be “is the best policy”.