C++ MCQs with answers Page - 11

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 given statements are false.
(i). extern int func;
(ii). extern int func2(int,int);
(iii). int func2(int,int);
(iv). extern class foo;

  • (A) (ii), (iii) and (iv)
  • (B) (iii) and (iv) only
  • (C) (ii) and (iii) only
  • (D) only (iv)

A

Admin • 833.24K Points
Coach

Q. Pick the right option
Statement (i) A definition is also a declaration.
Statement (ii) An identifier can be declared just once.

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

A

Admin • 833.24K Points
Coach

Q. Choose the correct option.
(i) extern int k;
(ii) int k;

  • (A) (i) declares and defines k, (ii) declares k
  • (B) both (i) and (ii) declare k
  • (C) (i) declares k, (ii) declares and defines k
  • (D) (i) declares the variable k and (ii) defines k

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int main()
    {
        int k;
        enum Month {
            January = 1, February ,March, April, May, June, July, August, September, October, November, December
        };
        for (k = April; k <= September; k++)
            cout << k;
        return 0;
    }
  • (A) 456789
  • (B) 0123456789101112
  • (C) 0123456
  • (D) 89101112

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int main()
    {
        enum channel {hotstar, zeetv, max};
        enum symbol {anamol, hotstar};
        int k = 0;
        for (k = hotstar; k <= zeetv; k++) {
           cout << k;
        }
        return 0;
    }
  • (A) Compilation Error
  • (B) Runtime Error
  • (C) Garbage Value
  • (D) hotstar

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    enum Gender {
        male, female, transgender
    };
    int main()
    {
        cout << male<< female<< transgender;
        return 0;
    }
  • (A) male
  • (B) female
  • (C) transgender
  • (D) 012

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    enum test 
    {
        p = 20, q, r
    };
    int main()
    {
        cout << p <<" " << q<< " " << r;
        return 0;
    }
  • (A) 20 21
  • (B) 21 22
  • (C) 20 21 22
  • (D) 20 22

A

Admin • 833.24K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    enum  boy
    {
        num = 20
    };
    int main()
    {
        int age = 100;
        age /= num;
        cout << "If you were boy, you would be " << age << endl;
        return 0;
    }
  • (A) If you were boy, you would be 5
  • (B) If you were boy, you would be 0
  • (C) If you were boy, you would be 10
  • (D) All of above

A

Admin • 833.24K Points
Coach

Q. Which of the following is not used to seek a file pointer?

  • (A) ios::cur
  • (B) ios::set
  • (C) ios::end
  • (D) ios::beg

A

Admin • 833.24K Points
Coach

Q. During dynamic memory allocation in CPP, new operator returns _________ value if memory allocation is unsuccessful.

  • (A) False
  • (B) NULL
  • (C) Zero
  • (D) None of these

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