C++ MCQs with answers Page - 10

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. Which of the following is the correct identifier?

  • (A) 2var_name
  • (B) 2VAR_NAME
  • (C) $varname
  • (D) var_name12

A

Admin • 833.24K Points
Coach

Q. Which of the following is not a type of inheritance?

  • (A) Multiple
  • (B) Multilevel
  • (C) Distributed
  • (D) Heirarchical

A

Admin • 833.24K Points
Coach

Q. What is an object in c++?

  • (A) It is function of class
  • (B) It is instance of class
  • (C) It is datatype of class
  • (D) It is part of the syntax of class

A

Admin • 833.24K Points
Coach

Q. Choose the right option

Code:
string* p, q;
  • (A) q is a pointer to a string, p is a string
  • (B) both p and q are pointers to string types
  • (C) p is a pointer to a string, q is a string
  • (D) All of above

A

Admin • 833.24K Points
Coach

Q. The operator used for dereferencing or indirection is ____

  • (A) –>>
  • (B) &
  • (C) *
  • (D) ->

A

Admin • 833.24K Points
Coach

Q. Identify the incorrect statements.

Code:
 int num = 23;
Statement (i):   int *ptr = &(num + 2);
Statement (ii):  int *ptr2 = #
Statement (iii): &&num = 50;
  • (A) Statement (ii) and (iii) are wrong
  • (B) Statement (i) and (iii) are wrong
  • (C) Statement (i) and (ii) are wrong
  • (D) All the three are wrong

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int main()
    {
        int p = 15;
        if (p < 13) {
            for (k = 0; k < 12; k++)
               cout << k;
        }
        else {
            cout << k;
        }
        return 0;
    }
  • (A) Compilation Error
  • (B) Runtime Error
  • (C) Garbage Value
  • (D) All of above

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    void Output()
    {
        static int p = 1;
        int k;
        for(k=p; k<=3; k++)
        {
        p++;
        cout << p;
        }
    }
    int main()
    {
        Output();
        Output();
        Output();
        return 0;
    }
  • (A) 0123
  • (B) 123
  • (C) 234
  • (D) 012345

A

Admin • 833.24K Points
Coach

Q. Can two functions declare variables(non static) with the same name.

  • (A) Yes
  • (B) No
  • (C) No, it gives a runtime error
  • (D) Yes, but not a very efficient way to write programs

A

Admin • 833.24K Points
Coach

Q. Pick the right option
Statement (i) Global values are not initialized by the stream.
Statement (ii) Local values are implicitly initialised to 0.

  • (A) Statement (i) is true, Statement (i) is false
  • (B) Statement (i) is true, Statement (ii) is false
  • (C) Both are true
  • (D) Both are false

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