computer MCQs

10th • Chapter 03

49 Questions TextBook
1

Which statements help decide the next statements to be executed based on a condition?

A
Sequential Statements
B
Selection Statements
C
Repetition Statements
D
Assignment Statements
2

What is the default control structure in the C language?

A
Selection control
B
Repetition control
C
Sequential control
D
Nested control
3

In an 'if' statement, the code gets executed only if the condition is what?

A
False
B
Zero
C
True
D
Negative
4

The condition inside an 'if' statement is enclosed in which symbols?

A
{}
B
[]
C
nan
D
()
5

A condition in an 'if' statement can be which type of expression?

A
Arithmetic
B
Relational
C
Logical
D
All of the above
6

In C, any expression that evaluates to a non-zero value is considered what?

A
False
B
Void
C
Error
D
True
7

An expression that evaluates to zero is considered what?

A
True
B
False
C
Null
D
Syntax Error
8

Which of the following expressions evaluates to 'true'?

A
5 == 4
B
5 - 5
C
5 > 4
D
(5 > 4) && (10 < 9)
9

For associating multiple statements with an 'if', they must be enclosed in what?

A
()
B
<>
C
{}
D
[]
10

What happens if the condition 'a > b' is false in the code: if (a > b) printf("A"); printf("B");?

A
Only A is printed
B
Only B is printed
C
Both A and B are printed
D
Nothing is printed
11

Which statement is used to execute a block of code if a condition is true and another block if it is false?

A
if statement
B
switch statement
C
if-else statement
D
nested if statement
12

An 'else' statement must be associated with which statement?

A
printf
B
main
C
if
D
switch
13

A set of multiple instructions enclosed in braces is called a?

A
Function
B
Array
C
Loop
D
Block or Compound Statement
14

The 'if-else-if' statement is also known as what?

A
if-else loop
B
if-else ladder
C
if-else chain
D
if-else switch
15

Conditional statements within other conditional statements are called what?

A
Complex structures
B
Parallel structures
C
Nested selection structures
D
Layered structures
16

In the expression 'if (condition)', what is 'if'?

A
A variable
B
A function
C
A keyword
D
A data type
17

Which operator is used for logical AND in C?

A
&
B
AND
C
&&
D
|
18

Which operator is used to check for equality?

A
0
B
0
C
-=
D
!=
19

What is the purpose of conditional logic in programming?

A
To repeat code
B
To make decisions
C
To store data
D
To declare variables
20

If percentage is 65, what grade is assigned by the code: if (p>=80) G='A'; else if (p>=70) G='B'; else if (p>=60) G='C';?

A
A
B
B
C
C
D
D
21

A flow chart uses a diamond shape to represent what?

A
Input/Output
B
Process
C
Start/Stop
D
Decision/Condition
22

In C, what does the expression '5 % 2 == 0' evaluate to?

A
True
B
False
C
1
D
Error
23

An 'if' statement inside another 'if' statement is an example of a _____ structure.

A
nested
B
boxed
C
repeated
D
decomposed
24

The code associated with an 'if' statement is executed when the condition is true. Otherwise...

A
the program crashes
B
the associated code does not get executed
C
the compiler skips the entire program
D
an error is generated
25

Which header file is typically required for 'printf' and 'scanf' functions?

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

What does the '!' operator do in a logical expression?

A
Logical AND
B
Logical OR
C
Logical NOT
D
Logical XOR
27

In an 'if-else-if' ladder, when is the final 'else' block executed?

A
Always
B
When the first 'if' is true
C
When all preceding conditions are false
D
When all preceding conditions are true
28

For a home user consuming 300 units of electricity, what is the unit price according to the PDF?

A
Rs 12
B
Rs 15
C
Rs 20
D
Rs 24
29

For a commercial user consuming 500 units of electricity, what is the unit price according to the PDF?

A
Rs 15
B
Rs 20
C
Rs 24
D
Rs 12
30

What is a 'compound statement'?

A
A statement with a condition
B
A statement that calls a function
C
Multiple statements enclosed in braces {}
D
A statement that declares a variable
31

If 'int a=15;', the condition 'a % 2 == 0' evaluates to what?

A
True
B
False
C
15
D
0
32

Which statement is NOT a type of control statement in C?

A
Sequential Control
B
Selection Control
C
Variable Control
D
Repetition Control
33

What is the primary function of a selection statement?

A
To repeat a set of instructions
B
To execute statements in sequence
C
To decide which statements to execute next
D
To stop the program
34

If you want to check if a character 'ch' is a digit, which condition can be used?

A
ch >= 0 && ch <= 9
B
ch >= '0' && ch <= '9'
C
ch == 'digit'
D
ch.isDigit()
35

What is the potential issue if you have multiple statements under an 'if' but do not use braces {} before an 'else'?

A
Slower execution
B
The code runs fine
C
Compiler error
D
Wasted memory
36

In the problem to find the largest of three numbers (n1, n2, n3), which condition checks if n1 is the largest?

A
n1 > n2 || n1 > n3
B
n1 > n2 && n1 > n3
C
n1 == n2 && n1 == n3
D
n1 < n2 && n1 < n3
37

A condition can be any valid expression EXCEPT?

A
Arithmetic
B
Relational
C
Declaration
D
Logical
38

Which of the following is a relational expression?

A
a + b
B
a && b
C
a > b
D
a = 5
39

In a flow chart, a rectangle is used to represent what?

A
Condition
B
Input/Output
C
Process
D
Connector
40

To get a bonus of Rs. 10000, what conditions must be met according to 'Programming Time 3.2'?

A
items_sold > 100
B
items_broken == 0
C
items_sold > 100 && items_broken == 0
D
items_sold > 100 || items_broken == 0
41

The structure where the program flow is a straight line, executing one statement after another, is called?

A
Selection
B
Sequential
C
Repetition
D
Branching
42

What does 'a % c == 0' check?

A
If c is a factor of a
B
If a is a factor of c
C
If a and c are equal
D
If a multiplied by c is 0
43

If a student's percentage is 49.9, what grade will they receive based on the logic in the PDF?

A
D
B
F
C
C
D
Error
44

In C, 'if' is a...

A
Reserved word/Keyword
B
User-defined function
C
Standard library
D
Variable
45

The statements that control the flow of execution of a program are called?

A
Flow statements
B
Control statements
C
Execution statements
D
Logic statements
46

In 'if (a > b)', 'a > b' is the?

A
Code
B
Keyword
C
Condition
D
Statement
47

What is the correct syntax for an 'if' statement in C?

A
if {condition} ()
B
if condition {}
C
if (condition) {}
D
if [condition] {}
48

The 'else' part of an 'if-else' statement is?

A
Mandatory
B
Optional
C
Required for compilation
D
Used to start a program
49

What is the output of: int x=5; if (x==5) printf("A"); else printf("B");?

A
A
B
B
C
AB
D
No output