Home / Programming Questions / C++ MCQs / Page 3

C++ MCQs with answers Page - 3

Dear candidates you will find MCQ questions of C++ here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    void function(int p, bool condition = true)
    {
        if (condition == true ) 
        {
            cout << "Condition is true. P = " << p;
        }
        else 
        {
            cout << "Condition is false. P = " << p;
        }
    }
    int main()
    {
        function(250, false);
        return 0;
    }
(A) Condition is true. P = 250
(B) 200
(C) Condition is false. P = 250
(D) True

U

Uday Singh • 7.23K Points
Tutor III

Q. Which value will it take when both user and default values are given?

(A) custom value
(B) default value
(C) user value
(D) All of above

U

Uday Singh • 7.23K Points
Tutor III

Q. Where can the default parameter be placed by the user?

(A) rightmost
(B) leftmost
(C) both rightmost & leftmost
(D) All of above

U

Uday Singh • 7.23K Points
Tutor III

Q. If the user did not supply the value, what value will it take?

(A) rise an error
(B) default value
(C) both rise an error & default value
(D) All of above

U

Uday Singh • 7.23K Points
Tutor III

Q. What will happen when we use void in argument passing?

(A) Maybe or may not be return any value to its caller
(B) It will not return value to its caller
(C) It will return value to its caller
(D) All of above

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int add(int p, int q);
    int main()
    {
        int n = 15, m = 16;
        cout << add(n, m) << endl;
        return 0;
    }
    int add(int p, int q )
    {
        int sum = p + q;
        p = 20;
        return p + q;
    }
(A) 36
(B) 15
(C) 16
(D) 20

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    void square (int *p)
    {
	*p = (*p + 1) * (*p);
    }
    int main ( )
    {
	int n = 11;
        square(&n);
        cout << n; 
        return 0;
    }
(A) 11
(B) 123
(C) 321
(D) 132

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the new value of P?

Code:
#include 
    using namespace std;
    void function(int &p)
    {
        p = 15;
    }
    int main()
    {
         int p = 12;
         function(p);
         cout << "New value of P is " << p;
         return 0;
    }
(A) New value of P is 12
(B) Compilation Error
(C) New value of P is 15
(D) Runtime Error

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.