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

C++ MCQs with answers Page - 2

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. How can you access the arguments that are manipulated in the function?

(A) arg_list
(B) va_list
(C) both arg_list & va_list
(D) All of above

U

Uday Singh • 7.23K Points
Tutor III

Q. Which header file is used to pass unknown number of arguments to function?

(A) stdarg.h
(B) stdlib.h
(C) string.h
(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 function(int p = 12, int q)
    {
        int s;
        s = p + q;
        return s;
    }
    int main()
    {
        cout << function(15);
        return 0;
    }
(A) 15
(B) 12
(C) Runtime Error
(D) Compilation Error

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the default return type of a function?

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

U

Uday Singh • 7.23K Points
Tutor III

Q. If we start our function call with default arguments means, what will be proceeding arguments?

(A) default arguments
(B) user argument
(C) empty arguments
(D) All of above

U

Uday Singh • 7.23K Points
Tutor III

Q. What we can’t place followed by the non-default arguments?

(A) default arguments
(B) trailing arguments
(C) both default & trailing arguments
(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;
    void function(int num1, int num2 = 12)
    {
        cout << "1st Number: " << num1<
        cout << "2nd Number: " << num2<   
      }
    int main()
    {
        function(2);
        function(5, 7);
        return 0;
    }
(A) 1st Number: 2 2nd Number: 12
(B) 1st Number: 5 2nd Number: 7
(C) 1st Number: 5 2nd Number: 7 1st Number: 2 2nd Number: 12
(D) 1st Number: 2 2nd Number: 12 1st Number: 5 2nd Number: 7

U

Uday Singh • 7.23K Points
Tutor III

Q. What is the output of this program?

Code:
#include 
    #include 
    using namespace std;
    string askMessage(string Message = "Please enter a message: ");
    int main()
    {
        string Input = askMessage();
        cout << "Here is your message: " << Input;
        return 0;
    }
    string askMessage(string Message)
    {
        string Input;
        cout << Message;
        cin >> Input;
        return Input;
    }
(A) Compilation Error
(B) Runtime Error
(C) Garbage value
(D) The message you entered

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.