55. What will be the output of following code :
// Assume all header files are included
main()
{
int i = 3;
for (;i++=0;) printf(“%d”,i);
}
A. 89
B. 0
C. compile time error
D. Runtime Error
View Answer & Explanation
Ans. c
Explanation : As we know that increment operators return rvalues and hence it cannot appear on the left hand side of an assignment operation.
56. What will be the output of following code :
// Assume all header files are included
void main()
{
static int i;
while(i<=10)
(i>2)?i++:i--;
printf(“%d”, i);
}
A. 32768
B. 32767
C. compile time error
D. Runtime Error
View Answer & Explanation
Ans. b
Explanation : Since i is static it is initialized to 0. Inside the while loop the conditional operator evaluates to false, executing i–. This continues till the integer value rotates to positive value (32767)
