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.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *