Find the output of C programs
Program 1
kw.c
#include <stdio.h>
int main()
{
    int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int i = 0, num;
    num = a[++i + a[++i]] + a[++i];
    printf("%d\n", num);
}
kodingwindow@kw:~$ gcc kw.c
kodingwindow@kw:~$ ./a.out 10 // a[2 + a[2]] + a[3] = a[5] + a[3] = 6 + 4 // a[1] = 2, a[2] = 3, a[5] = 6, a[3] = 4, hence the output is 10 kodingwindow@kw:~$
What Next?
C Functions
Advertisement