Structures


  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Condition
    {
    int n1;
    char n2;
    };
    int main()
    {
    struct Condition con1[] = {11, 91, 31, 14, 15, 16};
    struct Condition *ptr1 = con1;
    int n1 = (sizeof(con1) / sizeof(ptr1));
    if (n1 == 1)
    printf("%d\n", ptr1->n1);
    else
    printf("False\n");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    False


  1. What will be the output of the following C code?
    #include <stdio.h>
    struct City
    {
    };
    void main()
    {
    struct City c[2];
    printf("%d", sizeof(c));
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    0



  1. What will be the output of the following C code?
     #include <stdio.h>
    struct Option
    {
    int a;
    int b;
    };
    void fun(struct Option*);
    int main()
    {
    struct Option opt1[] = {13, 23, 33, 43};
    fun(opt1);
    }
    void fun(struct Option opt2[])
    {
    printf("%d\n", opt2[1].a);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    33


  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Number
    {
    int n1;
    int n2;
    };
    void function(struct Number*);
    int main()
    {
    struct Number num1[] = {15, 25, 35, 45};
    function(num1);
    }
    void function(struct Number num2[])
    {
    printf("%d\n", num2->n1);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    15



  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Team
    {
    int a;
    int b;
    };
    void function(struct Team*);
    int main()
    {
    struct Team t1[] = {100, 200, 300, 400};
    function(t1);
    }
    void function(struct Team t2[])
    {
    printf("%d %d\n", t2->a, ++t2->a);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    101 101