Google News
logo
CPP - Quiz(MCQ)
A)
structure creator
B)
structure signifier
C)
structure creator & signifier
D)
structure specifier

Correct Answer : Option (D) :   structure specifier


Explanation : The structure declaration with open and close braces and with a semicolon is also called structure specifier.

A)
isblank()
B)
isalpha()
C)
isdigit()
D)
isalnum()

Correct Answer : Option (C) :   isdigit()


Explanation : Character classification provides isdigit() function to check whether a character in C++ is number or not.

3 .
What will be the output of the following C++ code?
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char const *argv[])
{
	char arr[12] = "H3ll0\tW0r1d";
	for(int i=0;i<12;i++)
        {
		cout<<(bool)isprint(arr[i]);
	}
}​
A)
111110000000
B)
111110111110
C)
111000111110
D)
111111111110

Correct Answer : Option (B) :   111110111110


Explaination : In this program we are checking the presence of alphabets and digits in the string so accordingly one can find the answer.

A)
delete ptr[];
B)
delete[] ptr;
C)
[]delete ptr;
D)
delete ptr;

Correct Answer : Option (B) :   delete[] ptr;

A)
T operator++(int);
B)
T& operator++(int);
C)
T operator++();
D)
T& operator++();

Correct Answer : Option (A) :   T operator++(int);


Explanation : The parameter int is just to signify that it is the postfix form overloaded. Shouldn’t return reference as per its original behavior.

6 .
Which of the following is the correct syntax to add the header file in the C++ program?
 
#include<userdefined.h>
A)
#include<userdefined>
B)
#include "userdefined.h"
C)
<include> "userdefined.h"
D)
Both A and B

Correct Answer : Option (D) :   Both A and B


Explaination :

To include the herder files in the C++ program user can use any of the following given syntax.
 
#include <Filename.h>  
Or
#include "filename.h"  

A)
cout <<"Hello world!";
B)
Cout << Hello world! ;
C)
Out <<"Hello world!;
D)
None of the above

Correct Answer : Option (A) :   cout <<"Hello world!";


Explanation : To print the message in the C++ language user can use the following syntax :

#include <iostream>  
using namespace std;  
  
int main() {  
  cout << "Hello World!";  
  cout << "I am learning C++";  
  return 0;  
}  ​

A)
Encapsulation
B)
Polymorphism
C)
Inheritance
D)
All of the above

Correct Answer : Option (D) :   All of the above


Explanation : There is nothing that forces a user to use the OOP concept in C++. In contrast, it is necessary for a programming language that it must support all three features as encapsulation, inheritance, and polymorphism completely to become a pure Object-Oriented Language.

A)
Function call
B)
Type cast
C)
Array subscripting
D)
Addition and subtraction

Correct Answer : Option (B) :   Type cast


Explanation : There are many rights to left associativity operators in C++, which means they are evaluation is done from right to left. Type Cast is one of them. Here is a link of the associativity of operators: https://github.com/MicrosoftDocs/cpp-docs/blob/master/docs/cpp/cpp-built-in-operators-precedence-and-associativity.md

A)
equality
B)
shift
C)
postfix
D)
unary

Correct Answer : Option (C) :   postfix


Explanation : The operator which is having the highest precedence is postfix and lowest is equality.