C++ Beginner Quiz

1. How do you declare an integer variable in C++?

a) int x;
b) x = int;
c) integer x;
d) var x;

2. What is the output of `cout << 10 / 3;`?

a) 3.33
b) 3
c) 4
d) Error

3. True or False: C++ is case-sensitive.

a) True
b) False

4. What is the correct syntax for a for loop in C++?

a) for (int i = 0; i < 5; i++)
b) for i in range(5):
c) loop(i, 0, 5)
d) for (i = 0 to 5)

5. What does `cin >> x;` do?

a) Prints x
b) Reads input into x
c) Declares x
d) Increments x

6. What is used to include the I/O library?

a) #include
b) #include
c) import iostream
d) #include

7. How do you write a single-line comment in C++?

a) # Comment
b) // Comment
c)
d) /* Comment */

8. True or False: Variables must be declared with a type in C++.

a) True
b) False

9. What is the output of `cout << (5 > 3);`?

a) true
b) 1
c) 5
d) Error

10. What is the scope of a variable declared inside a block?

a) Global
b) Local to the block
c) File-wide
d) Permanent