C++ MCQs with answers Page - 144

Here, you will find a collection of MCQ questions on C++. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 5; cout << x++;

  • (A) 5
  • (B) 6
  • (C) 0
  • (D) Error

A

Admin • 833.24K Points
Coach

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

  • (A) int
  • (B) float
  • (C) real
  • (D) double

A

Admin • 833.24K Points
Coach

Q. What is the purpose of the 'new' operator in C++?

  • (A) To delete memory
  • (B) To allocate memory
  • (C) To initialize variables
  • (D) To define functions

A

Admin • 833.24K Points
Coach

Q. Which of the following is used to terminate a loop in C++?

  • (A) break
  • (B) exit
  • (C) stop
  • (D) return

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int a = 10; int b = 20; cout << (a > b ? a : b);

  • (A) 10
  • (B) 20
  • (C) 0
  • (D) Error

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to declare a pointer in C++?

  • (A) int ptr;
  • (B) int *ptr;
  • (C) *int ptr;
  • (D) int ptr*;

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int arr[3] = {1, 2, 3}; cout << arr[3];

  • (A) 1
  • (B) 2
  • (C) 3
  • (D) Undefined behavior

A

Admin • 833.24K Points
Coach

Q. Which of the following is used to define a macro in C++?

  • (A) #define
  • (B) #macro
  • (C) #include
  • (D) #ifdef

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int &ref = x; ref = 20; cout << x;

  • (A) 10
  • (B) 20
  • (C) 0
  • (D) Error

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a class in C++?

  • (A) class MyClass { };
  • (B) class MyClass { public: };
  • (C) class MyClass { private: };
  • (D) All of the above

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ