C++ Basic Syntax MCQs: Master C++ Programming Fundamentals
Enhance your knowledge of C++ programming with 30 MCQs focused on the basic syntax. Topics include the structure of a C++ program, input/output, data types, operators, and more. Perfect for beginners and intermediate learners.
1. What is the correct structure of a basic C++ program?
2. Which of the following is the correct syntax for printing output to the console in C++?
print("Hello, World!")echo "Hello, World!"cout << "Hello, World!";printf("Hello, World!");3. In C++, which symbol is used to indicate the end of a statement?
,;.:4. Which of the following is a valid C++ data type?
float32longintdoublecharacter5. What is the default value of an uninitialized local variable in C++?
6. Which keyword is used to declare a constant in C++?
constantstaticconstfinal7. Which of the following is a valid declaration of an integer variable in C++?
int 1x;int x;int x, y;8. What is the output type of cin in C++?
9. Which of the following is the correct way to read an integer input from the user in C++?
cin >> x;scanf("%d", x);read(x);input(x);10. Which operator is used to assign values to variables in C++?
===+=:=11. Which of the following operators is used for addition in C++?
+-*/12. What is the purpose of the relational operators in C++?
13. Which of the following is a valid relational operator in C++?
<<==&!=14. Which of the following is true about the && operator in C++?
15. Which of the following is a bitwise operator in C++?
&&&==||16. What does the bitwise | operator do in C++?
17. Which of the following is an arithmetic operator in C++?
!=+&&&18. What is the purpose of the ++ operator in C++?
19. Which of the following operators is used to perform division in C++?
/*-=20. Which operator is used to calculate the remainder in C++?
/*%&21. What will be the output of the following C++ expression: 10 % 3?
3101022. Which of the following is an example of a bitwise NOT operator in C++?
&|~!23. Which of the following operators is used for logical NOT in C++?
&|!~24. What does the bitwise shift left operator << do in C++?
25. What is the purpose of the = operator in C++?
26. What will be the output of the following C++ expression: 5 == 5?
truefalse1027. Which operator is used to compare two values for equality in C++?
===!==|28. Which of the following is true for the != operator in C++?
29. Which of the following is a valid assignment operator in C++?
===+=30. Which operator is used for compound assignment in C++?
=+=-=| QNo | Answer |
|---|---|
| 1 | C. Preprocessor directives, main function, return statement |
| 2 | C. cout << "Hello, World!"; |
| 3 | B. ; |
| 4 | C. double |
| 5 | C. Undefined |
| 6 | C. const |
| 7 | D. Both B and C |
| 8 | C. Stream |
| 9 | A. cin >> x; |
| 10 | B. = |
| 11 | A. + |
| 12 | B. To compare two values |
| 13 | B. == |
| 14 | A. It is used for logical AND |
| 15 | A. & |
| 16 | B. Performs bitwise OR |
| 17 | B. + |
| 18 | A. To increment a variable by 1 |
| 19 | A. / |
| 20 | C. % |
| 21 | B. 1 |
| 22 | C. ~ |
| 23 | C. ! |
| 24 | B. Shifts the bits of a number to the left |
| 25 | A. Assigns values |
| 26 | A. true |
| 27 | B. == |
| 28 | B. It checks if two values are not equal |
| 29 | D. All of the above |
| 30 | D. All of the above |