Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct calculation1
    {
    int n[2];
    };
    struct calculation2
    {
    int *n;
    };
    int main()
    {
    struct calculation1 cal1 = {10, 20};
    struct calculation2 *ptr1;
    ptr1->n = (struct q*)&cal1.n;
    printf("%d\n", ptr1->n[1]);
    }
    1. Segmentation fault
    2. Garbage value
    3. Compilation Error
    4. 20
    5. None of these
Correct Option: A

Segmentation fault



Your comments will be displayed only after manual approval.