Find the output of C programs
Program 1
kw.c
#include <stdio.h> int main() { int _ = 5, __ = 10, ___; ___ = _ + __; printf("%i\n", ___); return 0; }
Show OutputOutput
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out 15 kodingwindow@kw:~$
Program 2
kw.c
#include <stdio.h> int main() { int a = 20; { int a = 40; // variables can have same name in different scope } printf("%d\n", a); return 0; }
Show OutputOutput
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out 20 kodingwindow@kw:~$
Program 3
kw.c
#include <stdio.h> void main() { int x; x = 10, 20, 30; printf("%d\n", x); }
Show OutputOutput
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out 10 kodingwindow@kw:~$
Comments and Reactions
What Next?
C Control Statements
Advertisement