c Program Unit 2
c Program Unit 2
A) if a == b
B) if (a == b)
C) if {a == b}
D) if a = b
Answer: B) if (a == b)
A) for
B) while
C) if-else
D) do-while
Answer: C) if-else
3. What type of loop structure always executes its block of code at least once?
A) for loop
B) while loop
C) do-while loop
D) if-else
while (i < 3) {
i++;
A) 0 1 2
B) 1 2 3
C) 0 1 2 3
D) 1 2
Answer: A) 0 1 2
A) int array[10];
B) array int[10];
C) int array();
D) array[10];
A) break
B) return
C) continue
D) exit
Answer: C) continue
A) To execute one block of code out of many possible blocks based on a value
C) To handle exceptions
Answer: A) To execute one block of code out of many possible blocks based on a value
A) exit
B) continue
C) break
D) stop
Answer: C) break
A) int array[][];
B) int array[10][10];
C) int array(10)(10);
D) array[10,10];
A) for
Loop
B) while loop
C) if-else
D) do-while loop
Answer: C) if-else
12. Which of the following is the correct syntax for a for loop in C?
)13. Which loop will always execute the loop body at least once, even if the condition is false?
A) for
B) while
C) do-while
Answer: C) do-while
do {
i++;
A) 0 1 2
B) 0 1 2 3
C) 1 2 3
D) 1 2
Answer: A) 0 1 2
A) Stack
B) Queue
C) List
16. What is the correct way to declare a single-dimensional integer array of 5 elements in C?
A) int arr[];
B) int arr[5];
C) int arr(5);
D) int arr;
A) continue
B) return
C) break
D) exit
Answer: C) break
if (i == 10) {
printf("Ten");
} else {
printf("Not Ten");
A) Ten
B) Not Ten
C) 10
D) Error
Answer: A) Ten
19. In a switch statement, which keyword is used to skip to the next case after executing a case block?
A) continue
B) break
C) goto
D) exit
Answer: B) break
A) .
B) ->
C) []
D) {}
Answer: C) []
22. Which of the following types of loops is best for when the number of iterations is known?
A) while
B) do-while
C) for
D) if-else
Answer: C) for
A) int arr[2,3];
C) int arr[2] 3;
D) int arr{2}{3};
26.In a switch case statement what will happen if break is omitted form a case?
A) for loop
B) while loop
C) do while loop
A) loop
B) if else statement
D) both b and c
31.in the for loop how many times is the condition checked?
A) only once
Answer: C)
31.which statement is used to skip the remaining statements in the current iteration of a loop and proceed with the
next iteration?
A) break
B)continue
C)return
D)go to
Answer: B) continue
33. what happens when the break statement is udes in a nested loop?
34.In a for loop,which part is responsible for updating the loop counter?
A) initialization
B)condtion
C)increment/decrement
Answer: C) increment/decrement