C++ MCQs with answers Page - 151

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. Which of the following is the correct way to define a function with a reference parameter in C++?

  • (A) void myFunction(int &x) { }
  • (B) void myFunction(int x) { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x %= y);

  • (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 function with a const reference parameter in C++?

  • (A) void myFunction(const int &x) { }
  • (B) void myFunction(int &x) { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

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

  • (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 function with a pointer parameter in C++?

  • (A) void myFunction(int *x) { }
  • (B) void myFunction(int x) { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x |= y);

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

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a function with a const pointer parameter in C++?

  • (A) void myFunction(const int *x) { }
  • (B) void myFunction(int *x) { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following code snippet? int x = 10; int y = 20; cout << (x ^= y);

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

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct way to define a function with a const pointer to a const parameter in C++?

  • (A) void myFunction(const int *const x) { }
  • (B) void myFunction(int *const x) { }
  • (C) Both A and B
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. Which of the following is the correct syntax for a for loop in C++?

  • (A) for(int i=0; i<5; i++)
  • (B) for(int i=0; i<=5; i++)
  • (C) for(int i=0; i<5; i++) { }
  • (D) for(int i=0; i<5) { }

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