LogiQuest
Back to Structures, Unions, Enums
15

What will be the output of the program?

#include <stdio.h>
struct N { int v; struct N *next; };
int main(void) {
    struct N c = {3, NULL}, b = {2, &c}, a = {1, &b};
    int s = 0;
    struct N *p;
    for (p = &a; p; p = p->next) s += p->v;
    printf("%d\n", s);
    return 0;
}
Medium

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.