C Structures MCQ Questions and Answers
Q. What is a structure in C?
A user-defined data type that allows grouping of related data items.A built-in data type used to store data in memory.
A method to organize and manage data in an array.
A way to create functions that operate on specific data types.
Q. How do you declare a structure in C?
Using the struct keyword followed by the structure name and curly braces.Using the keyword data followed by the structure name and curly braces.
Using the #define directive followed by the structure name and curly braces.
Using the typedef keyword followed by the structure name and curly braces.
Q. How do you create a variable of a structure type?
By using the struct keyword followed by the structure name.By using the new keyword followed by the structure name.
By using the malloc() function to allocate memory for the structure.
By using the & operator to access the structure's memory address.
Q. How do you access members of a structure?
Using the . (dot) operator followed by the member name.Using the -> (arrow) operator followed by the member name.
Using the [] (bracket) operator followed by the member index.
Using the : (colon) operator followed by the member name.
Q. Can a structure contain another structure as a member?
Yes, a structure can contain another structure as a member.No, structures cannot contain other structures.
It depends on the compiler and the platform.
It is possible, but only if the inner structure is declared first.
Q. What is a structure pointer?
A pointer that points to a structure variable.A special type of pointer used only with structures.
A pointer that stores the address of a structure in memory.
A way to access and manipulate structures dynamically.
Q. How do you pass a structure to a function?
By value, using the struct keyword followed by the structure name.By reference, using the & operator followed by the structure variable name.
By value, using the * operator followed by the structure variable name.
By reference, using the address-of & operator followed by the structure variable name.
Q. Can you return a structure from a function?
Yes, you can return a structure from a function.No, you cannot return structures from functions.
You can return a structure by value, but not by reference.
You can return a pointer to a structure, but not the structure itself.