C++ MCQs with answers Page - 73

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 will be the output of the following C++ code?

Code:
#include <iostream>
using namespace std;
void fun(int x, int y){
    x = 20;
    y = 10;
}
int main() {

    int x = 10;
    fun (x, x);
    cout << x;
    
    return 0;
}
  • (A) 10
  • (B) 20
  • (C) 30
  • (D) Compile time error

A

Admin • 833.24K Points
Coach

Q. What is the scope of the variable declared in the user defined function?

  • (A) whole program
  • (B) only inside the {} block
  • (C) the main function
  • (D) header section

A

Admin • 833.24K Points
Coach

Q. How many minimum number of functions should be present in a C++ program for its execution?

  • (A) 0
  • (B) 1
  • (C) 2
  • (D) 3

A

Admin • 833.24K Points
Coach

Q. Which of the following is the default return value of functions in C++?

  • (A) int
  • (B) char
  • (C) float
  • (D) void

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include <iostream> 
    using namespace std;
    int main()
    {
        int num1 = 7;
        int num2 = 4;
        int num3 = 6;
        num1 = num2++;
        num2 = --num3;
        cout << num1 <<" " << num2 <<" " << num3;
        return 0;
    }
  • (A) 5 4 5
  • (B) 5 5 4
  • (C) 4 5 5
  • (D) Compilation Error

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include <iostream>  
    using namespace std;
    int main()
    {
        int num1 = 7, num2 = 3, Res;
        num1 = ++num1; 
        num2 = --num2;
        Res = num1 + ++num1;
        cout << Res;
        return 0;
    }
  • (A) 7
  • (B) 3
  • (C) 17
  • (D) 18

A

Admin • 833.24K Points
Coach

Q. The C++ code which causes abnormal termination/behaviour of a program should be written under _________ block.

  • (A) catch
  • (B) throw
  • (C) try
  • (D) finally

A

Admin • 833.24K Points
Coach

Q. What is Inheritance in C++?

  • (A) Deriving new classes from existing classes
  • (B) Overloading of classes
  • (C) Classes with same names
  • (D) Wrapping of data into a single class

A

Admin • 833.24K Points
Coach

Q. What will be the output of the following C++ code?

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

A

Admin • 833.24K Points
Coach

Q. Which of the following is not a storage class supported by C++

  • (A) register
  • (B) auto
  • (C) mutable
  • (D) dynamic

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