Data Types, Variables & Constants MCQs with Answers
Which of the following is a primitive data type in C?
a) String
b) Float
c) Array
d) Class
What is the default value of an uninitialized static integer in C?
a) 0
b) Null
c) Undefined
d) 1
Which of the following data types can store the largest integer value?
a) int
b) long
c) float
d) double
What type of variable is used to store a single character in C?
a) char
b) string
c) int
d) float
Which of the following is NOT a valid variable name in C?
a) int_var
b) _var123
c) 123var
d) varName
What is the size of a float variable in C?
a) 2 bytes
b) 4 bytes
c) 8 bytes
d) 16 bytes
Which of the following constants is used to define a constant value in C?
a) const
b) define
c) #define
d) static
What is the correct syntax for declaring a constant integer in C?
a) int const x = 10;
b) const int x = 10;
c) define int x = 10;
d) int x = 10; const
Which of the following is the size of the double data type in C?
a) 4 bytes
b) 8 bytes
c) 16 bytes
d) 2 bytes
Which keyword is used to define a constant in C?
a) define
b) const
c) constant
d) static
What is the output of the following C code?
int x = 5; printf(“%d”, x);
a) 0
b) 5
c) x
d) Undefined
Which of the following data types is used to store decimal values?
a) int
b) float
c) char
d) bool
Which of the following is the correct way to initialize a constant in C?
a) const int x = 10;
b) int const x = 10;
c) int x = 10; const
d) Both a and b
Which of the following is a valid constant declaration in C?
a) const int x = 10;
b) int x = 10; const
c) #define x 10
d) x = 10; const
What is the size of the char data type in C?
a) 1 byte
b) 2 bytes
c) 4 bytes
d) 8 bytes
Which data type can be used to store a boolean value in C?
a) int
b) char
c) bool
d) There is no boolean data type in C
Which of the following is the correct format specifier for a float variable in C?
a) %d
b) %f
c) %c
d) %s
What will be the output of the following C code?
int x = 10, y = 20; printf(“%d”, x + y);
a) 10
b) 20
c) 30
d) Undefined
Which of the following keywords is used to declare a variable in C that cannot be modified?
a) static
b) const
c) mutable
d) final
What is the range of values that can be stored in an unsigned int?
a) -2147483648 to 2147483647
b) 0 to 4294967295
c) -2147483648 to 0
d) 0 to 32767
What type of value does a char data type hold?
a) Boolean value
b) Integer value
c) Character value
d) Decimal value
Which of the following is a valid declaration of a pointer in C?
a) int *p;
b) pointer p;
c) int p*;
d) int* p;
Which of the following statements is true about the const keyword in C?
a) const can be used to declare both constants and variables
b) const variables cannot be modified
c) The const keyword can only be used with integer data types
d) const variables must be declared as global variables
What is the default value of a global static variable in C?
a) Null
b) 0
c) Undefined
d) 1
Which of the following is used to define a constant value in C?
a) #define
b) define
c) const
d) All of the above
Which data type is used to represent a very large integer in C?
a) int
b) long
c) long long
d) double
Which of the following will store the number 3.14 in a variable of type float?
a) float pi = 3.14;
b) float pi = 3.14f;
c) double pi = 3.14;
d) float pi = 3.14d;
What is the valid range of a signed char variable in C?
a) -128 to 127
b) 0 to 255
c) -32768 to 32767
d) 0 to 32767
Which of the following is an example of a constant in C?
a) const int x = 10;
b) #define x 10
c) x = 10;
d) Both a and b
Which data type is used to represent true or false values in C?
a) bool
b) char
c) int
d) There is no true/false data type in C
What is the purpose of the sizeof operator in C?
a) To calculate the size of a variable
b) To get the size of the memory
c) To return the size of a data type
d) To calculate the size of a constant