Which of the following is a valid way to declare multiple integer variables in C++?
A
int a = 5, b = 10, c = 15; B
int a, int b, int c; C
int a = 5; b = 10; c = 15; D
a = b = c = 5;
Analysis & Theory
You can declare and initialize multiple variables of the same type in a single statement like: int a = 5, b = 10, c = 15;
What will be the value of `b` after executing this code?
```cpp
int a = 10, b = a + 5;
```
A
5 B
10 C
15 D
20
Analysis & Theory
`b` is assigned the value of `a + 5`, which is 10 + 5 = 15.
Which of the following is incorrect when declaring multiple variables?
A
float x = 1.2, y = 3.4; B
char a = 'A', b = 'B'; C
double p = 3.14, int q = 5; D
bool isTrue = true, isFalse = false;
Analysis & Theory
You cannot mix types in a single declaration statement like `double p = 3.14, int q = 5;`.
Choose the correct syntax to declare three `int` variables without initializing them.
A
int a, b, c; B
int a = b = c = 0; C
a = int, b = int, c = int; D
declare int a, b, c;
Analysis & Theory
You can declare multiple `int` variables by separating them with commas: `int a, b, c;`.
Which of the following statements is true about multiple variable declarations?
A
Each variable must be declared in a separate line. B
You can assign the same value to all variables in one line using: int a = b = c = 0; C
You can use commas to declare multiple variables of the same type. D
C++ does not support declaring multiple variables.
Analysis & Theory
C++ allows multiple variables of the same type to be declared using commas, like: `int x, y, z;`.