C Variables MCQ Questions and Answers
Q. What is a variable in C programming?
A. A named storage locationB. A reserved keyword
C. A constant value
D. A data type
Q. What is the correct syntax to declare a variable in C?
A. <code>datatype variable_name;</code>B. <code>variable_name datatype;</code>
C. <code>datatype = variable_name;</code>
D. <code>variable_name = datatype;</code>
Q. What is the purpose of declaring a variable?
A. To reserve memory spaceB. To give a name to a memory location
C. To specify the data type of the value to be stored
D. All of the above
Q. What is variable initialization in C?
A. Assigning a value to a variable when it is declaredB. Declaring a variable without assigning a value
C. Specifying the data type of a variable
D. Giving a name to a variable
Q. What is the difference between declaration and definition of a variable?
A. Declaration specifies the type and name, while definition reserves memory and optionally initializes the variable.B. Declaration reserves memory, while definition specifies the type and name.
C. There is no difference.
D. Declaration initializes the variable, while definition only reserves memory.
Q. What is the output data type of the following expression? <code>int a = 5, b = 3; float result = a / b;</code>
A. floatB. int
C. double
D. char
Q. What is the output of the following code? <code>int x = 5; int y = ++x; printf("%d %d", x, y);</code>
A. 5 5B. 6 5
C. 6 6
D. 5 6
Q. What is the output of the following code? <code>int a = 10, b = 5; a = a & b; printf("%d", a);</code>
A. 10B. 5
C. 0
D. 1
Q. What is the purpose of the <code>const</code> keyword in C?
A. To declare a constant variableB. To declare a read-only variable
C. To make a variable unchangeable
D. All of the above