C Programming and Technical

Q. Predict the output or error
main()
{
int i=5,j=6,z;
printf("%d",i+++j);
}

A. 11

Explanation:the expression i+++j is treated as (i++ + j)

Read Solution (Total 0)

C Other Question

Q. Predict the output or error

A. main()
{
main();
}

A. Runtime error : Stack overflow.

Explanation: main function calls itself again and again. Each time the function is called it's return address is stored in the call stack. Since there is no condition to terminate the function call, the call stack overflows at runtime. So it terminates the program and results in an erro
Q. Predict the output or error
main()
{
int k=1;
printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
}

A. 1==1 is TRUE

Explanation: When two strings are placed together (or separated by white-space) they are concatenated (this is called as "stringization" operation). So the string is as if it is given as
"%d==1 is %s". The conditional operator( ?: ) evaluates to "TRUE".