Vidyalelo
C++ Programming · all questions

Introduction to C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

138

Questions

2/7

Page

Pick an option on a question to see the right answer and solution.

What does the 'static' keyword mean when used with a global variable in C++?

Select an option to see the answer and solution.

Which of the following is used to access the first element of an array in C++?

Select an option to see the answer and solution.

What is the output of the following code: cout << (5 == 5.0); in C++?

Select an option to see the answer and solution.

What is the purpose of the 'break' statement in a switch-case construct in C++?

Select an option to see the answer and solution.

What is the correct way to include a C++ standard library header file named 'vector' in a C++ program?

Select an option to see the answer and solution.

Which operator is used to access the member functions and variables of an object in C++?

Select an option to see the answer and solution.

What is the output of the following code: cout << (10 / 4); in C++?

Select an option to see the answer and solution.

What is the correct syntax to define a function named 'add' that takes two integers as parameters and returns their sum in C++?

Select an option to see the answer and solution.

Which of the following is not a valid data type in C++?

Select an option to see the answer and solution.

What does the 'new' operator return when memory allocation fails in C++?

Select an option to see the answer and solution.

Which of the following is the correct syntax for declaring a pointer to an integer in C++?

Select an option to see the answer and solution.

What is the output of the following code: cout << (5 < 2) ? "True" : "False"; in C++?

Select an option to see the answer and solution.

In C++, what is the purpose of the 'endl' manipulator?

Select an option to see the answer and solution.

What is the result of the expression: sizeof(char) in C++?

Select an option to see the answer and solution.

What does the 'const' keyword signify when used with a member function in a C++ class declaration?

Select an option to see the answer and solution.

Which operator is used to dereference a pointer in C++?

Select an option to see the answer and solution.

What is the correct way to include the C++ standard input/output library header file in a C++ program?

Select an option to see the answer and solution.

What is the output of the following code: int x = 5, y = 2; cout << x / y; in C++?

Select an option to see the answer and solution.

What is the correct syntax to define a class named 'Rectangle' with private member variables 'length' and 'width' in C++?

Select an option to see the answer and solution.

What is the output of the following code: cout << "Hello\nWorld"; in C++?

Select an option to see the answer and solution.