Google News
logo
CPP - Quiz(MCQ)
A)
Yes
B)
No, it is an enum of {false, true}
C)
No, it is expanded from macros
D)
No, it is a typedef of unsigned char

Correct Answer : Option (A) :   Yes


Explanation : C++ has bool as a fundamental data type.

A)
64
B)
128
C)
256
D)
512

Correct Answer : Option (B) :   128


Explanation : There are 128 characters defined in the C++ ASCII list.

A)
Unsigned integer of at least 64 bits
B)
Signed integer of at least 64 bits
C)
Unsigned integer of at least 16 bits
D)
Signed integer of at least 16 bits

Correct Answer : Option (C) :   Unsigned integer of at least 16 bits


Explanation : The size_t type is used to represent the size of an object. Hence, it’s always unsigned. According to the language specification, it is at least 16 bits.

A)
long double
B)
short float
C)
float
D)
double

Correct Answer : Option (B) :   short float


Explanation : Floating point types occur in only three sizes-float, long double and double.

A)
sizeof
B)
malloc
C)
calloc
D)
None of the above

Correct Answer : Option (A) :   sizeof


Explanation : The sizeof operator gives the size of the object or type.

A)
float
B)
string
C)
string & float
D)
integer

Correct Answer : Option (D) :   integer


Explanation : In C++, enumerations are stored as integers by the compiler starting with 0.

7 .
What does the following statement mean?
int (*fp)(char*)​
A)
pointer to a pointer
B)
pointer to an array of chars
C)
function taking a char* argument and returning a pointer to int
D)
pointer to function taking a char* argument and returns an int

Correct Answer : Option (C) :   pointer to function taking a char* argument and returns an int

A)
array[7];
B)
array[6];
C)
array(7);
D)
array(6);

Correct Answer : Option (B) :   array[6];


Explanation : The array location starts from zero, So it can accessed by array[6].

A)
0
B)
2
C)
4
D)
8

Correct Answer : Option (C) :   4


Explanation : Size of any type of pointer is 4 bytes in 32-bit platforms.

10 .
What will be the output of the following C++ code?

 #include 
   using namespace std;
   int main()
   {
       int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24};
       cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]];
       return 0;
   }​
A)
21 21 21
B)
15 18 21
C)
24 24 24
D)
Compile time error

Correct Answer : Option (A) :   21 21 21


Explaination :

a[1][2] means 1 * (4)+2 = 6th element of an array starting from zero.

Output :
$ g++ point.cpp
$ a.out
21 21 21​