You're developing a program to simulate a real-world scenario where different objects have different attributes like color, shape, and size. Which data type or concept in C would you use to efficiently represent these objects?
- To efficiently represent these objects, you can use a struct in C.
- To efficiently represent these objects, you can use an array of integers.
- To efficiently represent these objects, you can use a union in C.
- To efficiently represent these objects, you can use a constant variable.
The correct option is 1. Using a struct in C is the most suitable way to represent objects with different attributes like color, shape, and size. A struct can encapsulate these attributes within a single structure, allowing you to create objects with distinct characteristics. Arrays, unions, or constant variables would not be as appropriate for this purpose.
Loading...
Related Quiz
- What does a nested structure in C allow you to do?
- You are developing a library of mathematical functions. How can you design the library to allow users to apply custom operations on data without modifying the library code?
- Function pointers in C can be passed as arguments to functions, thereby providing a degree of ________.
- How is the size of a union determined in C?
- In C, using pointers to structures can lead to more efficient memory usage because it allows for ________ allocation and deallocation of memory.