Structures in C Language

This Test will cover Structure in C Langauge, including declaraction and initialization of structure, typedef, union etc.

Q. Which keyword is used to define a new structure?
Q. Which of the following is not true about a structure?
Q. __________ is a keyword used in C language to assign alternative names to existing types?

Q. What will be the output of following code?
main()
{
    struct student 
    {
        char name[20];
        int roll;
    };
    struct student s1 = { "adam", 101 };
    struct student s2 = s1;
    printf("%s", s2.name);
}
Q. What will be the output of the program?
#include<stdio.h>
struct course
{
    int courseno;
    char coursename[25];
};
int main()
{
    struct course c[] = { {102, "C"}, 
                          {103, "C++"}, 
                          {104, "Java"}     
                        };
    printf("%d ", c[1].courseno);
    printf("%s\n", (*(c+2)).coursename);
    return 0;
} 
Q. Point out the error in the code?
struct Student
{
    char[20] name;
    int rollno;
    struct Student s2;  
};
Q The .(dot) operator can be used to access structure elements using a structure variable. True or False?

Q. The size of a union is equal to __________?
Q. What will be the output of following code?
main()
{
    union std
    {
        int x;
        int y;
    };
    union std s1;
    s1.x =10;
    s1.y =20;
    printf("%d %d\n",s1.x, s1.y);
    return 0;
}
Q Is it necessary that the size of all elements in a union should be same?

SUBMIT TEST