CPP Data Types MCQ
Cpp MCQ- Home
- Tutorials
- Cpp
- Data Types
- Multiple Choice Question
(1) Which of the following function is used to find size in bytes of any data type ?
A) getsize
B) sizeof
C) printsize
D) size
Explanation
sizeof function is used to get size of any data type in C/C++.
(2) How many bytes occupied by int data type in C/C++ ?
A) 4
B) 6
C) 8
D) 10
Explanation
in most of C/C++ compiler int data type occupied 4 bytes. In some compiler it also take 2 bytes.
(3) Which of the following data type commonly used as counter variable.
A) int
B) float
C) doble
D) bool
Explanation
int data type store numeric values without decimal point. It is normally used in iterative structures as counter variable type.
(4) How many bytes occupied by float data type in memory ?
A) 2
B) 4
C) 6
D) 8
Explanation
float data type takes 4 bytes in memory. It is used to store small decimal values.
(5) Which of the following data type is used to store large decimal values
A) float
B) double
C) int
D) long
Explanation
double data type take 8 bytes in memory, while float data type take 4 bytes. So double data type is used to store large values.
(6) How many bytes does bool data type takes in memory ?
A) 1
B) 2
C) 3
D) 4
Explanation
Bool is boolean data type. It store either true or false ( 0 or 1). It takes only one byte in memory.
(7) Which of the following data type is used to store single character
A) double
B) int
C) float
D) char
Explanation
char (character) data type is used to store single character in variable. It may be Alphabet or Number.