What is a structure in C?
a) A user-defined data type that groups related variables of different types
b) A built-in data type for storing integers
c) A function that returns multiple values
d) A variable that stores a string
Answer:
a) A user-defined data type that groups related variables of different types
Explanation:
A structure in C is a user-defined data type that allows you to group related variables of different data types under a single name. Each variable within a structure is called a “member” or “field” of the structure. Structures are particularly useful for organizing complex data, such as representing a student with fields for name, age, and grade. The syntax for defining a structure involves the struct
keyword, followed by the structure name and a block containing the member declarations.
Understanding structures is essential for managing and organizing complex data in C programs, allowing you to create more modular and readable code.