C++ MCQs with answers Page - 19

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 in C++?

Code:
#include <iostream>
using namespace std;
int main()
{
  int a = 4;
  float b;
  cout << sizeof(++a + b) << endl;
  cout << a;
  return 0;
}
  • (A) 5 4
  • (B) 4 5
  • (C) 4 4
  • (D) 2 4

A

Admin • 833.24K Points
Coach

Q. Which of the following statements is equivalent to scanf() in C++?

  • (A) cin
  • (B) cout
  • (C) printf
  • (D) read

A

Admin • 833.24K Points
Coach

Q. Which of the following statements is equivalent to printf() in C++?

  • (A) cin
  • (B) cout
  • (C) scanf
  • (D) write

A

Admin • 833.24K Points
Coach

Q. What happens if the following program is run in C and C++?

  • (A) Error in C and C++
  • (B) Warning in C and C++
  • (C) Error in C++ but warning in C
  • (D) Error in C but warning in C++

A

Admin • 833.24K Points
Coach

Q. What is the difference between cin and scanf()?

  • (A) Both are the same.
  • (B) cin is a flow object while scanf() is a function.
  • (C) scanf() is a flow object while cin is a function.
  • (D) cin is used for displaying while scanf() is used to read inputs.

A

Admin • 833.24K Points
Coach

Q. What is the output of the following C++ code?

Code:
#include <iostream> 
using namespace std; 
int main() 
{ 
    char arr[4] = "abcd"; 
    cout << arr;     
    return 0; 
}
  • (A) abcd
  • (B) Warning
  • (C) Error: the string in the array is too long.
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What happens if the line below is executed in C and C++?

Code:
int *ptr = malloc(20);
  • (A) Error in C and C++
  • (B) Warning in C and C++
  • (C) Error in C++ and success in C
  • (D) Error in C and success in C++

A

Admin • 833.24K Points
Coach

Q. What is a dynamic binding?

  • (A) The process of binding the current code to a procedure call at runtime.
  • (B) The process of linking the actual code to a procedure call during compilation.
  • (C) Process of linking the current code to a procedure call at any time.
  • (D) All the answers are true

A

Admin • 833.24K Points
Coach

Q. What is a static binding?

  • (A) The process of binding the current code to a procedure call at runtime
  • (B) The process of linking the actual code to a procedure call during compilation.
  • (C) Process of linking the current code to a procedure call at any time.
  • (D) All the answers are true

A

Admin • 833.24K Points
Coach

Q. What happens if the line below is executed in C and C++?

Code:
const int x;
  • (A) Error in C and C++
  • (B) Warning in C and C++
  • (C) Error in C++ and success in C
  • (D) Error in C and success in C++

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