Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct MansWear
    {
    int size1;
    int size2;
    };
    struct WomensWear
    {
    int size1;
    int size2;
    };
    void fun(struct MansWear);
    int main()
    {
    struct WomensWear WW = {39, 42};
    fun(WW);
    }
    void fun(struct MansWear MW)
    {
    printf("%d\n", MW.size1);
    }
    1. Compilation Error
    2. 39
    3. 42
    4. Garbage value
    5. None of these
Correct Option: A

Compilation Error

main.c: In function ‘main’:
main.c:16:13: error: incompatible type for argument 1 of ‘fun’
fun(WW);
^~
main.c:12:10: note: expected ‘struct MansWear’ but argument is of type ‘struct WomensWear’
void fun(struct MansWear);



Your comments will be displayed only after manual approval.