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