MCQs based on Basics of C++ Programming
(For Beginners)
A) <!-- comment -->
B) ## comment
C) // comment
D) /* comment */
Answer: D
2. C++ is an extension of which language?
A) Java
B) Python
C) C
D) Pascal
Answer: C
3. Which of the following is the correct file extension of a C++ program?
A) .c
B) .cpp
C) .java
D) .py
Answer: B
4. Which function is the entry point of a C++ program?
A) start()
B) run()
C) main()
D) program()
Answer: C
5. Which header file is required for input and output in C++?
A) stdlib.h
B) conio.h
C) iostream
D) string
Answer: C
6. Which namespace is commonly used in C++ programs?
A) system
B) std
C) main
D) global
Answer: B
7. Which operator is used for output in C++?
A) >>
B) <<
C) ::
D) ==
Answer: B
8. Which data type is used to store decimal numbers?
A) int
B) char
C) float
D) bool
Answer: C
9. Which symbol is used to end a statement in C++?
A) :
B) .
C) ;
D) ,
Answer: C
10. Which of the following is a valid variable declaration?
A) int 1num;
B) int num1;
C) int num-1;
D) int num 1;
Answer: B
11. Which operator is used for comparison?
A) =
B) ==
C) ++
D) //
Answer: B
12. Which loop is guaranteed to execute at least once?
A) for
B) while
C) do-while
D) nested loop
Answer: C
13. Which keyword is used to define a constant variable?
A) fixed
B) const
C) constant
D) define
Answer: B
14. Which of the following is a correct single-line comment?
A) <!-- comment -->
B) ## comment
C) // comment
D) ** comment
Answer: C
15. Which of the following is a logical operator in C++?
A) &&
B) &
C) %
D) ^
Answer: A
No comments:
Post a Comment