computer MCQs
12th • Chapter 11
50 Questions TextBook
1
Which of the following is NOT a basic control structure mentioned in the text?
2
A group of statements enclosed in opening and closing braces is called a __________.
3
In a simple 'if' statement, when is the block of statements executed?
A
When the condition is falseC
When the condition is true 4
What is the value of a 'true' condition usually represented by in C?
5
What happens if you omit the braces for a single statement in an 'if' block?
C
It is optional and works correctlyD
It causes a runtime error 6
The 'if-else' statement is used to specify how many different choices?
7
What error occurs if you have an 'else' without a matching 'if'?
C
Illegal else without matching if 8
A nested 'if' statement refers to what?
A
An 'if' statement inside a loopB
An 'if' statement inside another 'if' statementC
Multiple 'if' statements in a sequenceD
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 speedC
It increases the complexityD
It is not allowed by the compiler 10
In a sequence of 'if' statements, how many conditions are tested?
B
Only until a true condition is foundC
All conditions are tested 11
Which statement is described as a good option for more than three alternatives to avoid the complexity of nested ifs?
12
In an 'if-else if' statement, what happens if all conditions are false?
B
The first block of statements is executedC
The statement following the final 'else' is executedD
No statement is executed 13
Which logical operator is represented by '&&' in C?
14
The 'switch' statement compares the value of an expression against a list of __________.
15
The value of the expression in a 'switch' statement must NOT be of which type?
16
What is the purpose of the 'break' statement within a 'switch' structure?
B
To skip the rest of the switch statement 17
What happens if 'break' statements are omitted from a 'switch' block?
A
Only the first true case executesC
Code from the first true case to the end of the switch executes 18
Which label in a 'switch' statement is executed if none of the case labels match?
19
The conditional operator (?:) is what type of operator?
20
In the expression 'condition ? true_case : false_case', what happens if the condition is false?
A
The true_case statement is executedB
The false_case statement is executed 21
Control structures are used to control the __________ of execution in a program.
22
Which control structure is also called the default flow?
23
According to the text, which of the following is a selection statement in C?
24
What will be the value of 'status' if the expression is 'status = (age > 60);' and age is 45?
25
Omitting braces in an 'if' block with multiple statements will cause what?
A
Only the first statement to be part of the 'if' blockC
The entire block to be part of 'if' 26
In an 'if-else if' ladder, when does the execution of the structure terminate?
A
After checking all conditionsB
When a true condition is found and its block is executedC
When a false condition is foundD
Only after the final 'else' block 27
Using logical operators can often __________ the program logic.
28
The case label in a switch statement can be which of these constant types?
29
In the case study, if both x- and y-coordinates are zero, the point lies at the __________.
30
If x-coordinate is negative (<0) and y-coordinate is positive (>0), the point lies in which quadrant?
31
What is a pictorial representation of a program called?
32
What is the purpose of the 'default' label in a 'switch' statement?
A
It is mandatory for all switch statementsB
It provides code to be executed if no case matchesC
It marks the beginning of the switch statementD
It is used to declare variables 33
Which header file includes the definition for the sqrt() function?
34
The expression in an 'if' statement is known as a __________.
35
If a condition is false, it is represented by the value __________.
36
The statement 'if (a > b && a > c)' contains what kind of condition?
37
What does a compound statement in C refer to?
A
A statement with a logical operatorB
A group of statements enclosed in bracesC
A statement that declares multiple variablesD
An assignment statement 38
Which of the a following is a repetition structure?
39
In the vowel/consonant checking example, why are two case labels used together (e.g., case 'a': case 'A':)?
B
It acts like a logical ORC
It acts like a logical ANDD
It is required for characters 40
If you have a sequence of 'if' statements, this can be inefficient because __________.
B
it always tests all conditionsC
it uses too much memoryD
it can cause syntax errors 41
The 'if-else if' statement is also known as a statement with __________ alternatives.
42
What will be printed if the code is 'a > b ? printf("A") : printf("B");' and a=5, b=10?
43
A solution that is a step-by-step procedure to solve a problem is an __________.
44
If y-coordinate is zero and x-coordinate is non-zero, the point lies on the __________.
45
What error does the compiler generate if a float is used in a switch expression?
B
Switch selection expression must be of integral type 46
The process of placing an 'if' statement inside another is called __________.
47
In the expression '(num > 0)', 'num' is a variable and '>' is a __________ operator.
48
When are braces mandatory for the body of an 'if' or 'else' statement?
C
When the body contains a single statementD
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 falseD
To handle syntax errors 50
Using logical AND (&&) to rewrite 'if (a > b) { if (a > c) }' simplifies it to __________.