Multiple choice Questions of C++ | C++ MCQ with Answer

1. Who invented C++?

a. Dennis Ritchie

b. Ken Thompson

c. Brian Kernighan

d. Bjarne Stroustrup

2. C++ language is a successor to which language?

a. B

b. C

c. Java

d. VB

3. What is C++?

a. C++ is an object-oriented programming language.

b. C++ is a procedural programming language.

c. C++ supports both procedural and object-oriented programming language.

d. C++ is a functional programming language.

4. The C++ language is ______ object-oriented language.

a. Pure Object oriented

b. Not Object oriented

c. Semi Object-oriented or Partial Object-oriented

d. None of the above

5. Which of the following approach is used by C++?

a. Left-right

b. Right-left

c. Bottom-up

d. Top-down

6. Identify the correct function from which the execution of C++ program starts?

a. new()

b. start()

c. pow()

d. main()

7. Which of the following is used for comments in C++?

a. /* comment */

b. // comment *

c. ///comment

d. Both // comment or /* comment */

8. Which of the following is used for single-line comment in C++?

a. //

b. \\

c. /* */

d. ##

9. Which of the following is used for multi-line comments in C++?

a. //

b. \\

c. /* */

d. ##

10. Why are comments used?

a. Make the program run faster

b. To help others read & understand the program

c. Increase the size of the executable program

d. Make a program compile easier

11. For inserting a new line in C++ program, which one of the following statements can be used?

a. \n

b. \r

c. \a

d. None of the above

12. Which one of the following represents the tab?

a. \n

b. \t

c. \r

d. None of the above

13. Which of the following header file is used to define cin, cout?

a. <iomanip.h>

b. <iostream.h>

c. <fstream.h>

d. None of the above

14. Which of the following is the correct syntax of including a user defined header files in C++?

a. #include[userdefined]

b. #include “userdefined”

c. #include<userdefined.h>

d. #include <userdefined>

15. What is cout?

a. Operator

b. Object

c. Function

d. Macro

16. The cin, cout are _________.

a. Library functions

b. Structures

c. Pointers

d. Objects

17. Which of the following is an insertion operator in C++?

a. << 

b. >> 

c. ->

d. <<< 

18. Which of the following is an extraction operator in C++?

a. >>>

b.  >> 

c. ->

d. <<<

 

19. Which of the following user-defined header file extension used in C++.

a. .c

b. .cpp

c. .h

d. .hf

20. What is the role of comments in a C++ program?

a. To optimize code execution

b. To define variables

c. To provide documentation and explanation

d. To declare constants

21. Which of the following is the correct syntax to print the message in C++ language?

a. Out<<”Hello World!;

b. cout<<”Hello World!”; 

c. Cout<<”Hello world!”;

d. None of the above

22. Which of the following is not a valid keyword in C++ language?

a. While

b. For

c. Switch

d. do-while

23. What is the purpose of the ‘const’ keyword in C++?

a. It declares a constant variable that cannot be modified after initialization.

b. It specifies a function that doesn’t change the state of an object.

c. It denotes a class that cannot be inherited.

d. It creates a copy of an object for use in a function.

24. Which of the following statement is correct about identifiers in C++?

a. Identifiers are the combination of alphanumeric characters that can be used for function and variable name.

b. Identifiers are a combination of alphanumeric characters that can be used for looping statements.

c. Both of the above

d. None of the above

25. What is a variable in C++?

a. A constant value

b. A data type

c. A storage location with a name

d. A keyword

26. Which of the following is not the basic type in C++?

a. Int

b. Float

c. Array

d. Char

27. What is the size of a long double in C++?

a. 8 bytes

b. 10 bytes

c. 12 bytes

d. 16 bytes

28.  The operator ‘+’ is?

a. Unary Operator

b. Binary Operator

c. Both Unary and Binary

d. None of the above

29. The operator ‘%’ is known as?

a. Division Operator

b. Modulus Operator

c. Percentage Operator

d. None of the above

30. In C++, what is the difference between == and =?

a. == is used for assignment, while = is used for comparison

b. == is used for comparison, while = is used for assignment

c. Both are used for assignment

d. Both are used for comparison

31. Which of the following operator is a ternary operator?

a. +=

b. !=

c. ::

d. ?:

32. Which of the following is not an arithmetic operator?

a. %

b. /

c. !

d. *

33.  Identify the logical AND operator.

a. ||

b. &

c. &&

d. !

34.  Identify the correct example for a pre-increment operator.

a. ++n

b. n++

c. – -n

d. +n

35. Identify the scope resolution operator.

a. :

b. ::

c. ?:

d. None

36.  By which of the following can the if-else statement be replaced?

a. Bitwise operator

b. Logical operator

c. Conditional operator

d. Arithmetic operator

37. What is correct syntax of a for loop in C++?

a. for(initialization; condition; increment/decrement)

b. for(increment/decrement; initialization; condition)

c. for(initialization, condition, increment/decrement

d. None of These

38. Choose the type of loop which is guaranteed to execute at-least once?

a. for loop

b. do-while

c. while

d. None

39. Which of the following refers to characteristics of an array?

a. An array is a set of similar data items

b. An array is a set of distinct data items

c. An array can hold different types of datatypes

d. None of the above

40. If we stored five elements or data items in an array, what will be the index address or the index number of the array’s last data item?

a. 3

b. 5

c. 4

d. 88

41. Which of the following correctly declares an array in C++?

a. int array{10};

b. array array[10];

c. int array;

d. int array[10];

42. Which of the following is the correct syntax for printing the address of the first element?

a. array[0];

b. array[1];

c. array[2];

d. None of the above

43. Which of the following gives the 4th element of the array?

a. Array[0];

b. Array[0];

c. Array[3];

d. None of the above

44. Which of the following is used to terminate the function declaration in C++?

a. ;

b. ]

c. )

d. :

45. What is an object in C++?

a. It is a function of class

b. It is an instance of the class

c. It is the data type of class

d. It is part of the syntax of class

46. To access data members of a class, which of the following is used?

a. Dot operator

b. Arrow operator

c. Dot or arrow operator as required

d. Dot arrow or direct call

47. Total access specifiers in OOPS for C++ are?

a. 1

b. 2

c. 3

d. 4

48. Total types of constructors in C++ are?

a. 1

b. 2

c. 3

d. 4

49. Which of the following is not a type of constructor in C++?

a. Default constructor

b. Parameterized constructor

c. Copy constructor

d. Friend constructor

50. What is the number of parameters that a default constructor requires?

a. 0

b. 1

c. 2

d. 3

8 thoughts on “Multiple choice Questions of C++ | C++ MCQ with Answer”

  1. Magnificent beat I would like to apprentice while you amend your site how can i subscribe for a blog web site The account helped me a acceptable deal I had been a little bit acquainted of this your broadcast offered bright clear idea

    Reply
  2. Ny weekly This is really interesting, You’re a very skilled blogger. I’ve joined your feed and look forward to seeking more of your magnificent post. Also, I’ve shared your site in my social networks!

    Reply
  3. Hello there! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good gains. If you know of any please share. Kudos!

    Reply

Leave a Comment