Find the output of C programs
Program 1
codeaft.c
#include <stdio.h> int main() { int x = 5; if (x == 5) printf("%d\n", !x); else printf("%d\n", x); return 0; }
Show OutputOutput
codeaft@codeaft:~$ gcc codeaft.c
codeaft@codeaft:~$ ./a.out 0 codeaft@codeaft:~$
Program 2
codeaft.c
#include <stdio.h> int main() { int x = 0; if (!x) printf("%d\n", !x); else printf("%d\n", x); return 0; }
Show OutputOutput
codeaft@codeaft:~$ gcc codeaft.c
codeaft@codeaft:~$ ./a.out 1 codeaft@codeaft:~$
Program 3
codeaft.c
#include <stdio.h> int main() { int x = 5; if (x) printf("%d\n", !x); else printf("%d\n", x); return 0; }
Show OutputOutput
codeaft@codeaft:~$ gcc codeaft.c
codeaft@codeaft:~$ ./a.out 0 codeaft@codeaft:~$
Comments and Reactions
What Next?
C Loops