Structures


  1. What will be the output of the following C code according to C99 standard?
     #include <stdio.h>
    struct S
    {
    int i;
    char ch;
    float flt;
    };
    int main()
    {
    struct S R = {.ch = 45, .i = 11, 31};
    printf("%f \n", R.flt);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    0.000000


  1. What will be the output of the following C code according to C99 standard?
    #include <stdio.h>
    struct stru
    {
    int i;
    char ch;
    float flt;
    };
    int main()
    {
    struct stru Res = {.ch = 333};
    printf("%f\n", Res.flt);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    0.000000



  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Employee
    {
    char *Name;
    };
    struct Employee emp1;
    struct Employee function(void)
    {
    emp1.Name = "Ajit";
    printf("%s\n", emp1.Name);
    emp1.Name = "Prayag";
    return emp1;
    }
    void main()
    {
    struct Employee emp2 = function();
    printf("%s\n", emp2.Name);
    emp2.Name = "Vivek";
    printf("%s\n", emp1.Name);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Ajit
    Prayag
    Prayag


  1. What will be the output of the following C code?
     #include <stdio.h>
    struct Employee
    {
    char *ch;
    struct Employee *point;
    };
    void main()
    {
    struct Employee e1;
    struct Employee *e2 = &e1;
    printf("%d", sizeof(Employee));
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c: In function ‘main’:
    main.c:11:29: error: ‘Employee’ undeclared (first use in this function)
    printf("%d", sizeof(Employee));
    ^~~~~~~~
    main.c:11:29: note: each undeclared identifier is reported only once for each function it appears in



  1. What will be the output of the following C code?
    #include <stdio.h>
    struct City
    {
    char *ch;
    };
    void main()
    {
    struct City c1;
    struct City *c2 = &c1;
    c2->ch = "Patna";
    printf("%s", c1.ch);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Patna