C MCQ Questions and Answers on Structures and Pointers 1

Image

Study C MCQ Questions and Answers on Structures and Pointers. C Structures are widely used in the code of hardware drivers and operating systems. Easily attend technical job interviews after reading these Multiple Choice Questions.

Go through C Theory Notes on Structures and Pointers before studying these questions.



1) What is a structure in C language.?
A) A structure is a collection of elements that can be of same data type.
B) A structure is a collection of elements that can be of different data type.
C) Elements of a structure are called members.
D) All the above
Answer [=]
Answer[=]
2) What is the size of a C structure.?
A) C structure is always 128 bytes.
B) Size of C structure is the total bytes of all elements of structure.
C) Size of C structure is the size of largest element.
D) None of the above
Answer [=]
Answer[=]
3) What is the output of C program with structures.?
int main()
{
    structure hotel
    {
        int items;
        char name[10];
    }a;
    strcpy(a.name, "TAJ");
    a.items=10;
    printf("%s", a.name);
    return 0;
}
A) TAJ
B) Empty string
C) Compiler error
D) None of the above
Answer [=]
Answer[=]
4) What is the output of C program.?
int main()
{
    struct book
    {
        int pages;
        char name[10];
    }a;
    a.pages=10;
    strcpy(a.name,"Cbasics");
    printf("%s=%d", a.name,a.pages);
    return 0;
}
A) empty string=10
B) C=basics
C) Cbasics=10
D) Compiler error
Answer [=]
Answer[=]
5) Choose a correct statement about C structures.
A) Structure elements can be initialized at the time of declaration.
B) Structure members can not be initialized at the time of declaration
C) Only integer members of structure can be initialized at the time of declaraion
D) None of the above
Answer [=]
Answer[=]
6) Choose a correct statement about C structure.?
int main()
{
    struct ship
    {

    };
    return 0;
}
A) It is wrong to define an empty structure
B) Member variables can be added to a structure even after its first definition.
C) There is no use of defining an empty structure
D) None of the above
Answer [=]
Answer[=]
7) What is the output of C program.?
int main()
{
    struct ship
    {
        int size;
        char color[10];
    }boat1, boat2;
    boat1.size=10;
    boat2 = boat1;
    printf("boat2=%d",boat2.size);
    return 0;
}
A) boat2=0
B) boat2=-1
C) boat2=10
D) Compiler error
Answer [=]
Answer[=]


 

8) What is the output of C program with structures.?
int main()
{
    struct ship
    {
        char color[10];
    }boat1, boat2;
    strcpy(boat1.color,"RED");
    printf("%s ",boat1.color);
    boat2 = boat1;
    strcpy(boat2.color,"YELLOW");
    printf("%s",boat1.color);
    return 0;
}
A) RED RED
B) RED YELLOW
C) YELLOW YELLOW
D) Compiler error
Answer [=]
Answer[=]
9) What is the output of C program with structures.?
int main()
{
    struct tree
    {
        int h;
    }
    struct tree tree1;
    tree1.h=10;
    printf("Height=%d",tree1.h);
    return 0;
}
A) Height=0
B) Height=10
C) Height=
D) Compiler error
Answer [=]
Answer[=]
10) Choose a correct statement about C structure elements.?
A) Structure elements are stored on random free memory locations
B) structure elements are stored in register memory locations
C) structure elements are stored in contiguous memory locations
D) None of the above.
Answer [=]
Answer[=]
11) A C Structure or User defined data type is also called.?
A) Derived data type
B) Secondary data type
C) Aggregate data type
D) All the above
Answer [=]
Answer[=]
12) What are the uses of C Structures.?
A) structure is used to implement Linked Lists, Stack and Queue data structures
B) Structures are used in Operating System functionality like Display and Input taking.
C) Structure are used to exchange information with peripherals of PC
D) All the above
Answer [=]
Answer[=]
13) What is the output of C program with structures.?
int main()
{
    struct tree
    {
        int h;
        int w;
    };
    struct tree tree1={10};
    printf("%d ",tree1.w);
    printf("%d",tree1.h);
    return 0;
}
A) 0 0
B) 10 0
C) 0 10
D) 10 10
Answer [=]
Answer[=]
14) What is the output of C program with structures.?
int main()
{
    struct tree
    {
        int h;
        int rate;
    };
    struct tree tree1={0};
    printf("%d ",tree1.rate);
    printf("%d",tree1.h);
    return 0;
}
A) 0 0
B) -1 -1
C) NULL NULL
D) Compiler error
Answer [=]
Answer[=]


 

15) What is the output of C program.?
int main()
{
    struct laptop
    {
        int cost;
        char brand[10];
    };
    struct laptop L1={5000,"ACER"};
    struct laptop L2={6000,"IBM"};
    printf("Name=%s",L1.brand);
    return 0;
}
A) ACER
B) IBM
C) Compiler error
D) None of the above
Answer [=]
Answer[=]
16) What is the output of C program with structures pointers.?
int main()
{
    struct forest
    {
        int trees;
        int animals;
    }F1,*F2;
    F1.trees=1000;
    F1.animals=20;
    F2=&F1;
    printf("%d ",F2.animals);
    return 0;
}
A) 0
B) 20
C) Compiler error
D) None of the above
Answer [=]
Answer[=]
17) What
int main()
{
    struct bus
    {
        int seats;
    }F1, *F2;
    F1.seats=20;
    F2=&F1;
    F2->seats=15;
    printf("%d ",F1.seats);
    return 0;
}
A) 15
B) 20
C) 0
D) Compiler error
Answer [=]
Answer[=]
18) What is the output of C program with structure arrays.?
int main()
{
    struct pens
    {
        int color;
    }p1[2];
    struct pens p2[3];
    p1[0].color=5;
    p1[1].color=9;
    printf("%d ",p1[0].color);
    printf("%d",p1[1].color);
    return 0;
}
A) 5 5
B) 5 9
C) 9 5
D) Compiler error
Answer [=]
Answer[=]
19) What is the output of C program with structure array pointers.?
int main()
{
    struct car
    {
        int km;
    }*p1[2];
    struct car c1={1234};
    p1[0]=&c1;
    printf("%d ",p1[0]->km);
    return 0;
}
A) 0
B) 1
C) 1234
D) Compiler error
Answer [=]
Answer[=]
20) Choose a correct statement about C structures.
A) A structure can contain same structure type member.
B) A structure size is limited by only physical memory of that PC.
C) You can define an unlimited number of members inside a structure.
D) All the above.
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Some good C Books

Book Price
1. C: The Complete Reference  Check Price
2. Let Us C Check Price
3. Programming in ANSI C Check Price
4. The C Programming Language Check Price

We may get some affiliate commission for the above purchases.