Determine Output:
void main(){ char not; not = !2; printf("%d", not);}

Determine Output:

void main(){ char not; not = !2; printf("%d", not);}
Correct Answer 0

! is a logical operator. In C the value 0 is considered to be the boolean value FALSE, and any non-zero value is considered to be the boolean value TRUE. Here 2 is a non-zero value so TRUE. !TRUE is FALSE (0) so it prints 0.

Related Questions

Determine output:
#include void main(){ char *p = NULL; char *q = 0; if(p) printf(" p "); else printf("nullp"); if(q) printf("q"); else printf(" nullq");}