Which of the following is a valid **declaration statement** in C?
A
int x; B
x = 10; C
print(x); D
scanf(x);
Analysis & Theory
`int x;` declares a variable. The others are not declaration statements.
Which of these is an **assignment statement**?
A
int x; B
x == 5; C
x = 5; D
printf(x);
Analysis & Theory
`x = 5;` assigns the value 5 to x. `==` is a comparison, not assignment.
What is the purpose of an **if statement**?
A
To repeat code B
To declare variables C
To perform arithmetic D
To make decisions
Analysis & Theory
`if` is a control statement used for decision-making in C.
Which of the following is the correct **if statement** syntax in C?
A
if x > 0 then {} B
if (x > 0) {} C
if x > 0 {} D
if x > 0:
Analysis & Theory
In C, conditions in `if` must be in parentheses, like `if (x > 0)`.
Which of the following is a **looping statement** in C?
A
if B
goto C
while D
switch
Analysis & Theory
`while` is a loop. `if` and `switch` are conditionals; `goto` is a jump.
What does a **switch statement** do?
A
Loops over a condition B
Branches code based on multiple cases C
Assigns values to variables D
Declares new variables
Analysis & Theory
`switch` evaluates an expression and runs matching `case` blocks.
Which statement is used to **exit a loop** early?
A
exit B
return C
break D
continue
Analysis & Theory
`break` exits the current loop or switch block immediately.
What is the purpose of the `continue` statement in C?
A
To end a program B
To skip the current iteration of a loop C
To start a new program D
To declare variables
Analysis & Theory
`continue` skips to the next iteration in a loop without completing the current one.
Which of the following is a **compound statement**?
A
x = 5; B
{ int a = 2; a++; } C
if (x > 0) D
break;
Analysis & Theory
A block enclosed in `{}` containing multiple statements is a compound statement.
Which of the following **control statements** allows you to jump to a labeled statement?
A
continue B
goto C
switch D
do-while
Analysis & Theory
`goto` allows jumping to a labeled part of the code. It's generally discouraged.