The document contains 10 multiple choice questions testing basic and intermediate C++ knowledge. The questions cover topics like variable declaration, I/O, constants, functions. The correct answers are provided.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
73 views2 pages
Basic C++ Quiz
The document contains 10 multiple choice questions testing basic and intermediate C++ knowledge. The questions cover topics like variable declaration, I/O, constants, functions. The correct answers are provided.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2
### Basic C++ Questions
1. Which of the following is the correct way to declare an integer variable in C++? - A) int x; - B) integer x; - C) x: int; - D) x integer; - Answer: A) int x;
2. What is the output of the following code?
```cpp int x = 10; cout << x; ``` - A) 10 - B) x - C) Error - D) 0 - Answer: A) 10
3. Which of the following is used to terminate a C++ statement?
- A) . - B) , - C) ; - D) : - Answer: C) ;
4. Which of the following is a correct comment in C++?
- A) // This is a comment - B) /* This is a comment */ - C) # This is a comment - D) A and B - Answer: D) A and B
5. Which of the following is not a C++ keyword?
- A) if - B) while - C) include - D) break - Answer: C) include
### Intermediate C++ Questions
6. What is the output of the following code?
```cpp int a = 5; int b = 3; cout << a + b; ``` - A) 8 - B) 53 - C) 5 + 3 - D) Error - Answer: A) 8
7. Which of the following is used for input in C++?
- A) cin - B) cout - C) scanf - D) printf - Answer: A) cin
8. How do you create a constant variable in C++?
- A) const int x = 5; - B) #de ne x 5 - C) constant int x = 5; - D) const int x; - Answer: A) const int x = 5;
9. What is the size of an int variable in C++?
- A) 2 bytes - B) 4 bytes - C) 8 bytes - D) It depends on the compiler and system - Answer: D) It depends on the compiler and system
10. What is the correct way to de ne a function in C++?
- A) int func() { return 0; } - B) function int func() { return 0; } - C) def func() { return 0; } - D) int func { return 0; } - Answer: A) int func() { return 0; } fi fi