C++ MCQs with answers Page - 28

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 instructions is illegal?

  • (A) string s, *p = 0;
  • (B) int *p;
  • (C) int i; double* p = &i;
  • (D) int *p = 0;

A

Admin • 833.24K Points
Coach

Q. Identify the type of variables.

Code:
typedef char* CHAR;
CHAR a,b;
  • (A) char
  • (B) char*
  • (C) CHAR
  • (D) CHAR*

A

Admin • 833.24K Points
Coach

Q. What is the output of the following C++ code?

Code:
#include <iostream>
using namespace std;
enum letter 
{
  A = 20, B, C
};
int main()
{
  cout << A << B << C;
  return 0;
}
  • (A) 202122
  • (B) 222120
  • (C) 202020
  • (D) None of the above

A

Admin • 833.24K Points
Coach

Q. What is the output of the following C++ code?

Code:
#include <iostream>
using namespace std;
enum Jour {
  MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
};
int main()
{
  cout << MONDAY << TUESDAY << WEDNESDAY << THURSDAY << FRIDAY;
  return 0;
}
  • (A) 01435
  • (B) 01234
  • (C) 43210
  • (D) 01235

A

Admin • 833.24K Points
Coach

Q. What is the output of the following C++ code?

Code:
#include <iostream>
using namespace std;
int main()
{
  int i, j;
  i = 1;
  j = (i++, i + 10, 9 + i);
  cout << j;
  return 0;
}
  • (A) 11
  • (B) 20
  • (C) 2
  • (D) 10

A

Admin • 833.24K Points
Coach

Q. How many instruction sequences are there in C++?

  • (A) 5
  • (B) 4
  • (C) 3
  • (D) 2

A

Admin • 833.24K Points
Coach

Q. The goto destination for the label is identified by __

  • (A) @
  • (B) $
  • (C) :
  • (D) %

A

Admin • 833.24K Points
Coach

Q. What is the output of the following C++ code?

Code:
#include <iostream>
using namespace std;
int main ()
{
  int i;
  for (i = 7; i > 0; i--)
  {
    cout << i;
    if (i == 5)
    break;
  }
  return 0;
}
  • (A) 7654
  • (B) 765
  • (C) 5
  • (D) 76

A

Admin • 833.24K Points
Coach

Q. How many comment types are there in C++?

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

A

Admin • 833.24K Points
Coach

Q. What is the output of the following C++ code?

Code:
#include <iostream>
using namespace std;
int main()
{
  int n = 5;
  for ( ; ;)
  cout << n;
  return 0;
}
  • (A) Display 5 infinitely
  • (B) Error
  • (C) 5
  • (D) None of the 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