computer MCQs

12th • Chapter 11

50 Questions TextBook
1

Which of the following is NOT a basic control structure mentioned in the text?

A
Sequence
B
Selection
C
Repetition
D
Declaration
2

A group of statements enclosed in opening and closing braces is called a __________.

A
Compound statement
B
Simple statement
C
Control structure
D
Function
3

In a simple 'if' statement, when is the block of statements executed?

A
When the condition is false
B
Always
C
When the condition is true
D
Never
4

What is the value of a 'true' condition usually represented by in C?

A
0
B
1
C
-1
D
Any non-zero value
5

What happens if you omit the braces for a single statement in an 'if' block?

A
It is a syntax error
B
It is a logical error
C
It is optional and works correctly
D
It causes a runtime error
6

The 'if-else' statement is used to specify how many different choices?

A
One
B
Two
C
Three
D
Multiple
7

What error occurs if you have an 'else' without a matching 'if'?

A
Undeclared identifier
B
Type mismatch
C
Illegal else without matching if
D
Syntax error
8

A nested 'if' statement refers to what?

A
An 'if' statement inside a loop
B
An 'if' statement inside another 'if' statement
C
Multiple 'if' statements in a sequence
D
An 'if' statement with a compound condition
9

According to the text, what is a primary drawback of increasing the level of nesting in 'if' statements?

A
It reduces program speed
B
It uses more memory
C
It increases the complexity
D
It is not allowed by the compiler
10

In a sequence of 'if' statements, how many conditions are tested?

A
Only the first one
B
Only until a true condition is found
C
All conditions are tested
D
Only the last one
11

Which statement is described as a good option for more than three alternatives to avoid the complexity of nested ifs?

A
switch
B
if-else if
C
goto
D
simple if
12

In an 'if-else if' statement, what happens if all conditions are false?

A
The program terminates
B
The first block of statements is executed
C
The statement following the final 'else' is executed
D
No statement is executed
13

Which logical operator is represented by '&&' in C?

A
OR
B
NOT
C
XOR
D
AND
14

The 'switch' statement compares the value of an expression against a list of __________.

A
variables
B
functions
C
cases
D
loops
15

The value of the expression in a 'switch' statement must NOT be of which type?

A
int
B
char
C
long
D
double
16

What is the purpose of the 'break' statement within a 'switch' structure?

A
To end the program
B
To skip the rest of the switch statement
C
To return a value
D
To repeat the case
17

What happens if 'break' statements are omitted from a 'switch' block?

A
Only the first true case executes
B
It's a syntax error
C
Code from the first true case to the end of the switch executes
D
No case will execute
18

Which label in a 'switch' statement is executed if none of the case labels match?

A
default
B
else
C
otherwise
D
none
19

The conditional operator (?:) is what type of operator?

A
Unary
B
Binary
C
Ternary
D
Logical
20

In the expression 'condition ? true_case : false_case', what happens if the condition is false?

A
The true_case statement is executed
B
The false_case statement is executed
C
Both are executed
D
The program exits
21

Control structures are used to control the __________ of execution in a program.

A
speed
B
flow
C
memory
D
data type
22

Which control structure is also called the default flow?

A
Selection
B
Repetition
C
Sequence
D
Function Call
23

According to the text, which of the following is a selection statement in C?

A
for
B
while
C
switch
D
do-while
24

What will be the value of 'status' if the expression is 'status = (age > 60);' and age is 45?

A
1
B
0
C
45
D
60
25

Omitting braces in an 'if' block with multiple statements will cause what?

A
Only the first statement to be part of the 'if' block
B
A compilation error
C
The entire block to be part of 'if'
D
The program to crash
26

In an 'if-else if' ladder, when does the execution of the structure terminate?

A
After checking all conditions
B
When a true condition is found and its block is executed
C
When a false condition is found
D
Only after the final 'else' block
27

Using logical operators can often __________ the program logic.

A
complicate
B
slow down
C
simplify
D
erase
28

The case label in a switch statement can be which of these constant types?

A
float
B
string
C
integral
D
double
29

In the case study, if both x- and y-coordinates are zero, the point lies at the __________.

A
x-axis
B
y-axis
C
origin
D
1st quadrant
30

If x-coordinate is negative (<0) and y-coordinate is positive (>0), the point lies in which quadrant?

A
1st
B
2nd
C
3rd
D
4th
31

What is a pictorial representation of a program called?

A
Algorithm
B
Pseudocode
C
Flow chart
D
Syntax diagram
32

What is the purpose of the 'default' label in a 'switch' statement?

A
It is mandatory for all switch statements
B
It provides code to be executed if no case matches
C
It marks the beginning of the switch statement
D
It is used to declare variables
33

Which header file includes the definition for the sqrt() function?

A
<stdio.h>
B
<string.h>
C
<conio.h>
D
<math.h>
34

The expression in an 'if' statement is known as a __________.

A
loop
B
condition
C
variable
D
function
35

If a condition is false, it is represented by the value __________.

A
1
B
0
C
true
D
-1
36

The statement 'if (a > b && a > c)' contains what kind of condition?

A
Simple
B
Compound
C
Relational
D
Arithmetic
37

What does a compound statement in C refer to?

A
A statement with a logical operator
B
A group of statements enclosed in braces
C
A statement that declares multiple variables
D
An assignment statement
38

Which of the a following is a repetition structure?

A
if-else
B
switch
C
for loop
D
conditional operator
39

In the vowel/consonant checking example, why are two case labels used together (e.g., case 'a': case 'A':)?

A
It is a syntax error
B
It acts like a logical OR
C
It acts like a logical AND
D
It is required for characters
40

If you have a sequence of 'if' statements, this can be inefficient because __________.

A
it is hard to read
B
it always tests all conditions
C
it uses too much memory
D
it can cause syntax errors
41

The 'if-else if' statement is also known as a statement with __________ alternatives.

A
one
B
two
C
no
D
multiple
42

What will be printed if the code is 'a > b ? printf("A") : printf("B");' and a=5, b=10?

A
A
B
B
C
AB
D
Nothing
43

A solution that is a step-by-step procedure to solve a problem is an __________.

A
flowchart
B
algorithm
C
compiler
D
interpreter
44

If y-coordinate is zero and x-coordinate is non-zero, the point lies on the __________.

A
y-axis
B
origin
C
x-axis
D
4th quadrant
45

What error does the compiler generate if a float is used in a switch expression?

A
Type Mismatch
B
Switch selection expression must be of integral type
C
Illegal use of float
D
Undefined symbol
46

The process of placing an 'if' statement inside another is called __________.

A
looping
B
recursion
C
sequencing
D
nesting
47

In the expression '(num > 0)', 'num' is a variable and '>' is a __________ operator.

A
logical
B
arithmetic
C
relational
D
assignment
48

When are braces mandatory for the body of an 'if' or 'else' statement?

A
Always
B
Never
C
When the body contains a single statement
D
When the body contains multiple statements
49

What is the final 'else' in an 'if-else if' chain used for?

A
To catch all conditions that were false
B
To start the chain
C
It is mandatory
D
To handle syntax errors
50

Using logical AND (&&) to rewrite 'if (a > b) { if (a > c) }' simplifies it to __________.

A
if (a > b || a > c)
B
if (a > b && a > c)
C
if (a > b, a > c)
D
if (a && b > c)