Posted on: November 24, 2022
Hello students welcome to CSE Study247 Today I am provide you MCQ on Structure and Union in c.
This page provide 20 Multiple choice question with Answer that is very useful of Computer science students like preparation of many exam Like ( ISRO,DRDO ,Semester, Interview, TCS , Railway & another Government Sector)
❤️ TOP 500+ C Programming Question and Answer
C programming is the basic language of programming that help to learn another language. So this MCQ is very useful for you.
C is a general purpose ,high level language that originally developed by Dennis Ritchie to develop the UNIX operating system at Bell labs.
Q.1 Structure is a _____ data type.
A)
Predefine
B)
User Define
C)
Can't be said
D)
None
Discuss it
Explanation
A structure is a user-defined data type in C that allows you to combine different data types under a single name.
View Solution
Q.2 Structure members are accessed using the _____ operator.
A)
dot
B)
assignment
C)
logical
D)
None
Discuss it
Explanation
The dot operator (.) is used to access members of a structure variable.
View Solution
Q.3 Union is a?
A)
Primitive data type
B)
User define data type
C)
Both A & B
D)
None
Discuss it
Explanation
Like a structure, a union is a user-defined data type where all members share the same memory location.
View Solution
Q.4 A C Structure or User defined data type is also called?
A)
Secondary data type
B)
Derived data type
C)
Both A & B
D)
None
Discuss it
Explanation
Structures are categorized as both secondary and derived data types because they are constructed using primary data types.
View Solution
Q.5 Find out the output: struct man { int c; } man1; man1.c=4; printf('Child=%d', man1.c);
A)
Child
B)
Child=0
C)
Child=4
D)
Compiler Error
Discuss it
Explanation
The program assigns the value 4 to the member 'c' of structure variable 'man1' and prints it correctly.
View Solution
Q.6 Which of the following allows to combine data items of different kinds?
A)
Array
B)
Function
C)
Structure
D)
None
Discuss it
Explanation
A structure is used to group variables of different data types, whereas an array groups variables of the same data type.
View Solution
Q.7 The restriction with union initialization is?
A)
The last member can be initialized
B)
The first member can be initialized
C)
Any member can be initialized
D)
None
Discuss it
Explanation
In standard C (C89), only the first member of a union can be explicitly initialized.
View Solution
Q.8 Which of the following operations is illegal in structures?
A)
Pointer to a variable of the same structure
B)
Typecasting of structure
C)
Dynamic allocation of memory for structure
D)
None
Discuss it
Explanation
You cannot typecast a whole structure to another type directly; however, you can typecast a pointer to a structure.
View Solution
Q.9 Which of the following uses structure?
A)
Array of structure
B)
Linked list
C)
Binary tree
D)
All of these
Discuss it
Explanation
Complex data structures like linked lists, trees, and arrays of records are implemented using structures.
View Solution
Q.10 Number of bytes in memory taken by: struct test { int a; char b; };
A)
Multiple of word size
B)
integer size + character size
C)
can't be said
D)
None
Discuss it
Explanation
The total size is the sum of the sizes of its members, though compilers may add padding for alignment.
View Solution
Q.11 In a structure, the operator '.' is called as?
A)
period operator
B)
dot operator
C)
Both A & B
D)
None
Discuss it
Explanation
The '.' operator is formally known as the member access operator, but is commonly called the dot or period operator.
View Solution
Q.12 A structure is used when we wish to store _____ data.
A)
Dissimilar
B)
Similar
C)
Identical
D)
None
Discuss it
Explanation
Structures are designed to store a collection of dissimilar data types (e.g., an int and a string together).
View Solution
Q.13 Identify the correct statement regarding nested members?
A)
Union can be member of structure
B)
Structure can be member of union
C)
Both A & B
D)
None
Discuss it
Explanation
C allows nesting where a union can be a member of a structure and vice versa.
View Solution
Q.14 Which of the following cannot be a structure member?
A)
Array
B)
Function
C)
Structure
D)
None
Discuss it
Explanation
A structure can contain a pointer to a function, but it cannot contain a function definition as a member.
View Solution
; } a; strcpy(a.name,’computer’); a.items=525; printf(‘Name=%s items=%d’,a.name,a.items);” a=”Compiler Error” b=”Garbage value” c=”Name=computer items=525″ d=”None” correct=”c” ans=”The members are correctly assigned using string copy and direct assignment, then printed as per the format string.”]
Q.16 A structure is a?
A)
collection of elements that can be of same data type
B)
Elements of a structure are called members
C)
collection of elements that can be of different data type
D)
All of these
Discuss it
Explanation
A structure groups members of potentially different types, and each element within it is referred to as a member.
View Solution
”Q.17
A)
”&”
B)
”*”
C)
”::”
D)
”->”
View Solution
Q.18 Which operator connects the structure name to its member name?
Discuss it
Explanation
For a regular structure variable, the dot operator (.) is used to connect the variable name to the member name.
View Solution
Q.19 Which of the following are themselves a collection of different data types?
A)
String
B)
Structure
C)
Char
D)
int
Discuss it
Explanation
A structure is a compound data type specifically designed to hold a collection of different types.
View Solution
; float marks; } std[12];” a=”40″ b=”12″ c=”480″ d=”28″ correct=”c” ans=”A union’s size is the size of its largest member (40 bytes). Since there is an array of 12 unions, the total size is 12 * 40 = 480 bytes.”]
1. Official Telegram Click Here 2. Telegram For CSE MCQs Click Here 3. You Tube Click Here