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

C++ MCQs with answers Page - 4

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 copy (int& p, int& q, int& r)
    {
        p = p * 1;
        q = q * 2;
        r = r * 3;
    }
    int main ()
    {
        int m = 6, n = 3, o = 2;
        copy (m, n, o);
        cout << "M = " << m << ", N = " << n << ", O = " << o;
        return 0;
    }
(A) M = 6, N = 6, O = 6
(B) N = 6, O = 6, M = 6
(C) O = 6, M = 6
(D) Compilation Error

U

Uday Singh • 7.23K Points
Tutor III

Q. By default how the value are passed in c++?

(A) call by reference
(B) call by pointer
(C) call by value
(D) All of above

U

Uday Singh • 7.23K Points
Tutor III

Q. Which is used to keep the call by reference value as intact?

(A) const
(B) absolute
(C) static
(D) All of above

U

Uday Singh • 7.23K Points
Tutor III

Q. How many ways of passing a parameter are there in c++?

(A) 4
(B) 3
(C) 2
(D) 1

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the use of the function “showbase”?

(A) Function Argument
(B) Indicate the base used
(C) Indicate the variable
(D) Indicate the base used & variable

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the output of this program?

Code:
#include <iostream>
    using namespace std;
    int main()
    {
        unsigned long num = 56;
        cout << num << oct <<" " << num << endl;
        return 0;
    }
(A) 56
(B) 70
(C) 70 56
(D) 56 70

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the output of this program?

Code:
#include <iostream>
    #include <iomanip>
    using namespace std;
    void showDate(int mm, int dd, int yy)
    {
        cout << setfill('0');
        cout << setw(2) << mm << '/'
        << setw(2) << dd << '/'
        << setw(4) << yy << endl;
    }
    int main()
    {
        showDate(1, 1, 2019);
        return 0;
    }
(A) 01
(B) 02
(C) 2019
(D) 01/01/2019

U

Uday Singh • 7.23K Points
Tutor III

Q. Which function allows you to set minimum width for the next input?

(A) setwidth
(B) setfill
(C) setw
(D) All of above

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.