C++ MCQs with answers Page - 4

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 • 802.91K Points
Coach

Q. Choose the correct formatted code.

  • (A) int main() { cout << 10;}
  • (B) int main(){ cout << “10”}
  • (C) int main() { cout << “10”; }
  • (D) All of above

A

Admin • 802.91K Points
Coach

Q. What is the use of the indentation in c++?

  • (A) r distinguishes between comments and outer data
  • (B) distinguishes between comments and code
  • (C) both a and b
  • (D) to write multi line comment in c++

A

Admin • 802.91K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    long fact (long p)
    {
        if (p > 1)
            return (p * fact (p + 1));
        else
            return (1);
    }
    int main ()
    {
        long n = 6;
        cout << n << "! = " << fact ( n );
        return 0;
    }
  • (A) 1
  • (B) 6
  • (C) segmentation fault
  • (D) compile time error

A

Admin • 802.91K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    void square (int *p)
    {
	*p = (*p + 3) * (*p);
    }
    int main ( )
    {
	int n = 15;
        square(&n);
	cout << n;
	return 0;
    }
  • (A) 207
  • (B) 270
  • (C) 15
  • (D) 3

A

Admin • 802.91K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int add(int p, int q);
    int main()
    {
        int k = 7, L = 9;
        cout << add(k, L) << endl;
        return 0;
    }
    int add(int p, int q )
    {
        int sum = p + q;
        p = 10;
        return p + q;
    }
  • (A) 7
  • (B) 9
  • (C) 10
  • (D) 19

A

Admin • 802.91K Points
Coach

Q. What is used to write multi line comment in c++?

  • (A) /$ …. $/
  • (B) //
  • (C) /* …. */
  • (D) All of above

A

Admin • 802.91K Points
Coach

Q. What is the output of this program?

Code:
#include 
    using namespace std;
    int main()
    {
        /* this is comment*
        cout << "Uday";
        return 0;
    }
  • (A) Uday
  • (B) Compilation Error
  • (C) Runtime Error
  • (D) Garbage value

A

Admin • 802.91K Points
Coach

Q. What type of comments does c++ support?

  • (A) multiline
  • (B) single line
  • (C) multi-line and single line
  • (D) All of above

A

Admin • 802.91K Points
Coach

Q. What is a comment in c++?

  • (A) comments are executable
  • (B) comments are parts of the source code disregarded by the compiler
  • (C) comments are executed by the compiler to find the meaning of the comment
  • (D) All of above

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