You are developing an application that needs to represent a value that could either be an integer or a floating-point number. How could you efficiently represent this data using C?
- Using a linked list
- Using a structure
- Using a union
- Using an array
In C, a union allows you to efficiently represent data that can be either an integer or a floating-point number, as it allows sharing the same memory location for different data types. Arrays, structures, and linked lists are not suitable for this purpose.
Loading...
Related Quiz
- What is the behavior of malloc when the size requested is zero?
- When using pointers in a C program, what does the 'dereferencing' operation do?
- The ________ directive is used to define symbolic names or constants in a C program.
- What is the time complexity of the linear search algorithm in the worst case?
- What is the main difference between function declaration and function definition in C?