C++ Multiple Choice Questions
1. What is the result of the following code?
#include <iostream> using namespace std; int main() { int a = 7; int b = 2; cout << a % b << endl; return 0; }
2. What is the output of the following code?
#include <iostream> using namespace std; int main() { float a = 3.5; int b = 2; cout << a / b << endl; return 0; }
3. Which of the following statements about data types is true?
4. What will the following code output?
#include <iostream> using namespace std; int main() { bool flag = true; cout << !flag << endl; return 0; }
5. What is the result of the following expression?
#include <iostream> using namespace std; int main() { int x = 5; x += 10; cout << x << endl; return 0; }
6. Which operator is used to perform the bitwise OR operation in C++?
7. What is the output of this code?
#include <iostream> using namespace std; int main() { int x = 7; cout << ++x << endl; return 0; }
8. What is the output of the following code?
#include <iostream> using namespace std; int main() { char ch = 'B'; cout << ch + 1 << endl; return 0; }
9. Which operator is used for logical AND in C++?
10. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 10; x *= 3; cout << x << endl; return 0; }
11. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 10; cout << x-- << endl; return 0; }
12. What is the result of this expression?
#include <iostream> using namespace std; int main() { float x = 7.0; int y = 3; cout << x / y << endl; return 0; }
13. Which operator is used for bitwise XOR operation in C++?
14. What will the following code output?
#include <iostream> using namespace std; int main() { int a = 5; int b = 4; cout << a + b * 2 << endl; return 0; }
15. What will be the output of this code?
#include <iostream> using namespace std; int main() { float a = 2.5; int b = 4; cout << a * b << endl; return 0; }
16. Which of the following is a correct way to declare a `short` integer variable in C++?
17. What will be the output of this code?
#include <iostream> using namespace std; int main() { int x = 3; int y = 5; cout << (x + y) * (x - y) << endl; return 0; }
18. What will be the output of the following code?
#include <iostream> using namespace std; int main() { char ch = 'Z'; cout << ++ch << endl; return 0; }
19. Which of the following is used for modulo division in C++?
20. What will the following code print?
#include <iostream> using namespace std; int main() { int x = 5; int y = 4; cout << x % y << endl; return 0; }
21. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int a = 8; int b = 3; cout << a / b << endl; return 0; }
22. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 4; int y = 5; cout << (x + y) * 2 << endl; return 0; }
23. What is the result of the following operation: 10 % 3 in C++?
24. Which of the following statements is true about the `char` data type in C++?
25. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 10; int y = x++; cout << y << endl; cout << x << endl; return 0; }
26. What is the result of the following operation: 5 * 2 >> 1 in C++?
27. Which of the following is a correct statement about the `++` operator in C++?
28. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 4; int y = 3; cout << x * y << endl; return 0; }
29. Which of the following is the correct syntax to declare a variable `x` of type `float`?
30. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 7; int y = 3; cout << (x % y) + 1 << endl; return 0; }
31. What is the size of `int` on a typical 32-bit system?
32. What will be the output of the following code?
#include <iostream> using namespace std; int main() { float a = 1.2f; double b = 1.2; cout << (a == b) << endl; return 0; }
33. Which of the following is a valid way to declare a variable in C++?
34. What is the output of the following code?
#include <iostream> using namespace std; int main() { int x = 10; cout << ++x << endl; return 0; }
35. Which operator is used to perform integer division in C++?
36. What is the output of the following code?
#include <iostream> using namespace std; int main() { int x = 8; cout << x / 3 << endl; return 0; }
37. Which of the following is the correct syntax to declare a constant variable in C++?
38. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int a = 7; int b = 3; cout << a % b << endl; return 0; }
39. What is the result of `5 + 3 * 2` in C++?
40. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int a = 15; cout << a / 4 << endl; return 0; }
41. What is the size of `char` in C++?
42. Which of the following data types can store floating-point numbers in C++?
43. What is the output of the following code?
#include <iostream> using namespace std; int main() { int a = 2; int b = 3; cout << a++ * ++b << endl; return 0; }
44. Which operator is used to compare two values in C++?
45. What will be the output of the following code?
#include <iostream> using namespace std; int main() { bool flag = true; cout << !flag << endl; return 0; }
46. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 9; cout << x % 4 << endl; return 0; }
47. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 5; int y = x++; cout << y << endl; return 0; }
48. Which data type is used to store a single character in C++?
49. What is the result of `10 / 3` in C++ when `10` and `3` are integers?
50. What is the correct syntax for declaring a `double` variable in C++?
51. Which of the following is not a valid data type in C++?
52. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int a = 5; int b = 10; cout << a + b * 2 << endl; return 0; }
53. What is the correct way to declare a variable `score` of type `int` and initialize it to 100?
54. Which of the following is used to perform logical AND operation in C++?
55. What is the result of `7 % 3` in C++?
56. What is the correct syntax for a `for` loop in C++?
57. Which of the following data types is used for boolean values in C++?
58. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 2; int y = 4; cout << x * y / 2 << endl; return 0; }
59. What is the correct way to declare a variable `price` of type `float`?
60. What is the output of the following code?
#include <iostream> using namespace std; int main() { int a = 10; cout << a-- << endl; return 0; }
61. What is the output of the following code?
#include <iostream> using namespace std; int main() { int a = 8; int b = 3; cout << a / b << endl; return 0; }
62. What will be the output of the following code?
#include <iostream> using namespace std; int main() { double a = 5.5; int b = 2; cout << a / b << endl; return 0; }
63. What is the size of a `long long` variable on most systems?
64. Which of the following is the correct syntax for using a `switch` statement in C++?
65. Which of the following data types has the largest size in C++?
66. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int a = 3; int b = 2; cout << a / b << endl; cout << a % b << endl; return 0; }
67. Which of the following is a valid floating-point literal in C++?
68. What is the output of the following code?
#include <iostream> using namespace std; int main() { int a = 1; int b = 2; cout << a + b * 2 << endl; return 0; }
69. Which of the following is the correct way to declare an array of 5 integers in C++?
70. What is the output of the following code?
#include <iostream> using namespace std; int main() { int a = 3; int b = 4; cout << ++a + b++ << endl; return 0; }
71. What is the output of the following code?
#include <iostream> using namespace std; int main() { int a = 5; int b = 10; cout << (a < b ? a : b) << endl; return 0; }
72. Which of the following statements is true about `unsigned int`?
73. What is the size of a `short` variable on most systems?
74. Which operator is used to access members of a structure in C++?
75. What is the output of the following code?
#include <iostream> using namespace std; int main() { int x = 5; x *= 3; cout << x << endl; return 0; }
76. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int a = 5; int b = 10; cout << (a > b) << endl; return 0; }
77. Which of the following is a correct statement about `const` variables in C++?
78. What is the default value of a `bool` variable in C++ if not explicitly initialized?
79. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 7; cout << (x % 3 == 1) << endl; return 0; }
80. Which operator is used for equality comparison in C++?
81. What is the output of the following code?
#include <iostream> using namespace std; int main() { int a = 10; cout << a++ << endl; cout << a << endl; return 0; }
82. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 4; int y = 5; cout << x > y ? x : y << endl; return 0; }
83. Which of the following is a valid integer literal in C++?
84. What is the result of the following operation: 7 & 3 in C++?
85. Which of the following operators has the highest precedence in C++?
86. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 10; cout << x-- << endl; cout << x << endl; return 0; }
87. What is the result of the operation 5 ^ 3 in C++?
88. What is the result of the operation 5 << 1 in C++?
89. What is the output of the following code?
#include <iostream> using namespace std; int main() { bool flag = true; cout << !flag << endl; return 0; }
90. What is the output of the following code?
#include <iostream> using namespace std; int main() { int x = 5; x += 10; cout << x << endl; return 0; }
91. What is the output of the following code?
#include <iostream> using namespace std; int main() { int a = 5; int b = 5; cout << (a == b) << endl; return 0; }
92. Which of the following is a correct statement about the `sizeof` operator in C++?
93. What is the size of an `int` variable on most systems?
94. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 10; int y = 20; cout << (x > y ? x : y) << endl; return 0; }
95. Which of the following is a correct statement about `float` in C++?
96. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int x = 7; x /= 2; cout << x << endl; return 0; }
97. What will be the output of the following code?
#include <iostream> using namespace std; int main() { int a = 5; int b = 2; cout << (a % b) << endl; return 0; }
98. What is the result of the operation 3 * 2 > 5 in C++?
99. Which of the following operators has the lowest precedence in C++?
100. What is the output of the following code?
#include <iostream> using namespace std; int main() { int x = 10; x += 5; x -= 3; cout << x << endl; return 0; }
Thank You for Visiting!
We are deeply grateful for your time and attention. Your engagement with our content means a lot to us, and we hope that the information provided has been valuable and insightful for your C++ journey.
We strive to create resources that empower and inspire. If you found our content useful, please consider sharing it with others who might benefit from it. Your support helps us continue to provide quality content and make a difference in the programming community.
If you have any feedback, suggestions, or questions, we’d love to hear from you. Feel free to reach out through our contact page or leave a comment. Together, let's continue to learn and grow in the fascinating world of C++ programming!
Thank you once again for your visit. Keep coding and stay curious!