What is the purpose of the 'sizeof' operator in C?
A. Calculate square root
B. Determine size
C. Perform division
D. Convert to string
Answer: Option B
Solution (By Examveda Team)
The purpose of the 'sizeof' operator in C is to determine the size of a data type or a variable in bytes. It is used to find out how much memory is allocated to a specific data type or an object in memory.So, the correct answer is:
Option B: Determine size
Here's an example of how 'sizeof' operator is used in C:
int size = sizeof(int);
printf("Size of int: %d\n", size);
In this example, 'sizeof(int)' will return the size (in bytes) of the 'int' data type, and it will be stored in the 'size' variable. It is a valuable operator when you need to work with memory allocation and management in C.
Join The Discussion