What is the output?
#include <stdio.h>
void main(){
int x = -1, y = 1, z = 0;
if(x && y++ && z)
++x, y++, --z;
printf("%d, %d, %d", x++, y++, z++);
}x && y++ && z, since z = 0, the logical AND short-circuits and the body of the if is not executed.
However, y++ is evaluated before the short-circuit, so y becomes 2.
Values before printing:
$$ x = -1,\ y = 2,\ z = 0 $$
So the program prints:
$$ (-1,\ 2,\ 0) $$
Online Test Series, Information About Examination,
Syllabus, Notification
and More.
Online Test Series, Information About Examination,
Syllabus, Notification
and More.