Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Count
    {
    int m;
    int n;
    };
    void fun(struct Count*);
    int main()
    {
    struct Count c1[] = {14, 24, 34, 44, 54};
    fun(c1);
    }
    void fun(struct Count c2[])
    {
    printf("%d %d\n", c2->m, (c2 + 2).n);
    }
    1. 24
    2. 34
    3. 44
    4. 54
    5. Compilation Error
Correct Option: E

Compilation Error

main.c: In function ‘fun’:
main.c:15:42: error: ‘c2 + 16’ is a pointer; did you mean to use ‘->’?
printf("%d %d\n", c2->m, (c2 + 2).n);



Your comments will be displayed only after manual approval.