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.
Related Questions on C Fundamentals
What is the primary purpose of a function prototype in C?
A. Declare a variable
B. Declare a function
C. Define a function
D. Assign a value
What is the correct syntax for declaring a variable in C?
A. int variable_name;
B. variable_name = 5;
C. variable_name int;
D. int = variable_name;
Join The Discussion