computer MCQs

12th • Chapter 12

49 Questions TextBook
1

Which of the following is NOT a loop construct in C?

A
for
B
while
C
if-else
D
do-while
2

The repetition of a set of statements in a program is called a what?

A
selection
B
sequence
C
iteration
D
a loop
3

In a while loop, the condition is checked at the ____ of the loop.

A
end
B
beginning
C
middle
D
after each statement
4

Which loop guarantees that the body is executed at least once?

A
for
B
while
C
do-while
D
nested loop
5

A variable whose value controls the number of iterations is known as a ____.

A
counter
B
loop control variable
C
sentinel
D
flag
6

In a while loop, where is the loop control variable typically initialized?

A
Inside the loop body
B
Outside the loop body
C
In the loop condition
D
It is not initialized
7

What character must be at the end of a do-while statement?

A
A colon (:)
B
A period (.)
C
A semicolon (;)
D
No special character
8

Which part of the for loop is mandatory and cannot be omitted?

A
Initialization expression
B
Test condition
C
Increment/decrement expression
D
The loop body
9

A loop inside the body of another loop is called a ____.

A
complex loop
B
sentinel loop
C
nested loop
D
infinite loop
10

An end marker that follows the last item in a list of items is called a ____.

A
terminator
B
end value
C
final flag
D
sentinel value
11

What is the term for the statements that are executed when the loop's condition is true?

A
The loop condition
B
The body of the loop
C
The loop syntax
D
The loop iteration
12

The 'goto' statement performs what kind of transfer of control?

A
Conditional
B
Unconditional
C
Temporary
D
Functional
13

In type casting, a variable of one type behaves as another type ____.

A
permanently
B
only for output
C
temporarily
D
within the function
14

How many expressions are there in a standard for loop statement, separated by semicolons?

A
One
B
Two
C
Three
D
Four
15

Which operator was used in Example 2 to combine the sub-conditions for input validation?

A
|| (OR)
B
&& (AND)
C
! (NOT)
D
0
16

An increase in the level of nesting generally increases the ____ of the loop.

A
speed
B
complexity
C
readability
D
scope
17

In a 'for' loop, the initialization expression is executed how many times?

A
For every iteration
B
Only once
C
Twice
D
Never
18

A label is meaningful only to which statement?

A
while
B
for
C
switch
D
goto
19

What could be a potential issue if the 'if (total_students > 0)' check is omitted in Example 4?

A
Syntax error
B
Compiler warning
C
Infinite loop
D
Runtime error (division by zero)
20

Using '(float)total_students' is an example of what?

A
Function call
B
Variable declaration
C
Type casting
D
Pointer arithmetic
21

In a 'for' loop like 'for(;;)', what kind of loop is created?

A
A loop that runs once
B
A loop that does not run
C
An infinite loop
D
A syntax error
22

In Example 1, what is the purpose of 'count = count + 1;'?

A
To initialize the counter
B
To check the condition
C
To print the value
D
To increment the loop control variable
23

The do-while loop checks the test condition after executing the ____.

A
initialization
B
loop body
C
first statement
D
last statement
24

Which expression in a 'for' loop is optional?

A
Test condition
B
Initialization and increment/decrement
C
Loop body
D
Semicolons
25

In Example 3, which loop acts as the outer loop?

A
while loop
B
do-while loop
C
for loop
D
There is no outer loop
26

What is the general form of a sentinel-controlled loop?

A
Process, then get data
B
Get data, then process in a loop
C
Get all data first, then loop
D
Loop indefinitely
27

The 'goto' statement requires a ____ to transfer control to.

A
function name
B
variable
C
label
D
header file
28

The phenomenon where the fractional part is truncated in integer division is avoided by using?

A
doubles
B
type casting
C
long int
D
pointers
29

If the condition in a while loop is false initially, the loop body executes how many times?

A
At least once
B
Once
C
Zero times
D
Infinitely
30

In the syntax 'while (condition)', the parentheses are ____.

A
optional
B
mandatory
C
used for comments
D
used for initialization
31

The compound statement enclosed in braces in a loop is called the ____.

A
loop head
B
loop body
C
loop tail
D
loop block
32

Which loop is preferred by most programmers because of its flexibility?

A
while
B
do-while
C
for
D
goto
33

In a nested loop, the ____ loop completes all its iterations for each single iteration of the ____ loop.

A
outer, inner
B
inner, outer
C
first, second
D
second, first
34

A sentinel value must be a value that could ____ occur as normal data.

A
always
B
frequently
C
sometimes
D
not normally
35

The process of converting one data type into another is known as?

A
Type conversion
B
Type casting
C
Type modification
D
Type declaration
36

What is the third type of program control structure mentioned, besides sequence and selection?

A
Function
B
Array
C
Pointer
D
Iteration
37

In the code 'for (count = 1; count <= 10; count++)', what is 'count <= 10'?

A
Initialization
B
Loop body
C
Test condition
D
Increment expression
38

When does a 'for' loop terminate?

A
When the initialization fails
B
When the condition becomes false
C
When the increment expression is zero
D
After 100 iterations by default
39

What happens immediately after the body of a 'while' loop is executed?

A
The loop terminates
B
Control jumps back to the condition check
C
The loop control variable is re-initialized
D
The next statement outside the loop is executed
40

In a 'do-while' loop, if the condition is false on the first check, how many times has the body run?

A
Zero
B
Once
C
Twice
D
It depends
41

What is the output of the first iteration of the loop in Example 1?

A
1
B
0
C
10
D
No output
42

Which header file is needed for the 'sqrt()' function used in Example 5?

A
<stdio.h>
B
<string.h>
C
<stdlib.h>
D
<math.h>
43

Omitting the semicolon at the end of a 'do-while' loop will cause a ____.

A
runtime error
B
logical error
C
syntax error
D
warning
44

In a 'for' loop, if the increment/decrement part is omitted, where must the loop control variable be updated?

A
Outside the loop
B
In the initialization part
C
Inside the loop body
D
It cannot be updated
45

Which statement allows repeating a set of statements up to a fixed number of times or until a criterion is met?

A
if statement
B
switch statement
C
Loop statement
D
goto statement
46

The keyword 'do' lets the program flow move into the body of the loop without checking any ____.

A
syntax
B
variable
C
test condition
D
header file
47

In Example 3, the variable 'outer' is initialized to what value in the first iteration?

A
1
B
7
C
0
D
inner
48

A negative number was chosen as a sentinel value in Example 4 because ____.

A
it is easy to type
B
it is the default
C
a student cannot have negative marks
D
it stops the program faster
49

The 'label' in a 'goto' statement must be in the same ____.

A
loop
B
file
C
function
D
header