Q1) What is the final value of i after executing the code:
For (int i = 1; i < 5; i+=2)
- 7
- 6
- 5
- 9
Answer:5
Explanation:It initializes a variable i with an initial value of 1, then it checks if i is less than 5. If that's true, it executes the code inside the loop, which is i+=2, adding 2 to the current value of i after each iteration of the loop.
So, in the first iteration of the loop, i has a value of 1. After executing i+=2, the value of i becomes 3. In the second iteration, i is 3, and after executing i+=2 again, the value of i becomes 5.
Since i is now equal to 5, which is not less than 5, the loop ends and the final value of i is 5.
Q2) __________ is a loop statement.
OR Which of the following is a loop statement in C Language?
- lf
- If -else
- Switch
- For
Answer:For
Explanation:
Q3) If you want a user to enter exactly 20 values, which loop would be the best to use?
- Do- while
- While
- Infinite
- FOR
Answer:For
Explanation:Both for and while loops can be used to achieve this. However, a for loop might be more suitable in this scenario as it provides a clear and concise way to execute a block of code a specific number of times.
Q4) This statement may be used to stop a loop current iteration and begin next one:
- Increment
- Break
- Decrement
- Continue
Answer:Break
Explanation:In C programming language, the break statement is a control statement that is used to immediately terminate the execution of a loop. When break is encountered within a loop, the loop is exited immediately, and the program control is transferred to the statement immediately following the loop.
The break statement is often used within loops such as for, while, and do-while loops to provide a way to exit the loop prematurely based on some condition.
Q5) This is a control structure that case a statement or group of statements to repeat: (DGK-19)
- Decision statement
- Loop
- Sequential
- Logical
Answer:Loop
Explanation:This is a loop control structure.
Q6) The part of for loop executes only once:
- Condition
- Increment
- Decrement
- Initialization
Answer:Initialization
Explanation: The initialization part of a for loop executes only once, before the loop begins executing. The initialization part sets the initial value for the loop control variable.
Q7) How many types of loop structure are present?
- 1
- 2
- 3
- 4
Answer:3
Explanation:There are three types of loop structures:
For loop
While loop
Do-While loop
Q8) Which of the following is not a Loop structure in C?
- While
- Condition
- Do- While
- For
Answer:Condition
Explanation:Condition
Q9) Which is an example of multiple branches from single expression?
- If statement
- For loo
- While loop
- Switch statement
Answer:Switch statement
Explanation:The use of a switch statement can result in more efficient and readable code than multiple if-else statements. However, it is typically only used when there are a significant number of cases to evaluate.
Q10) Which of the following loop is available in C?
- While- wend
- For- next
- Do- while
- Sequence
Answer:Do- while
Explanation:Do- while
Q11) This is good choice when you know how many times you want to loop to iterate in advance of entering the loop.
- While
- For
- Do-While
- Nested
Answer:For
Explanation:A "for loop" is a control flow statement that repeatedly executes a block of code until a specified condition is met. It is a good choice when you know how many times you want to loop to iterate in advance of entering the loop.
Q12) A loop within a loop is called:
- Complex
- Compound
- Nested
- Infinite
Answer:Nested
Explanation:Nested loops refer to a situation where a loop statement is present inside another loop statement. In other words, it means that there is one loop inside the body of another loop.
Q13) One execution of a loop is knowa as
- Test
- Iteration
- Duration
- Cycle
Answer:Iteration
Explanation:Iteration refers to the repetition of a process or set of instructions in a computer program, usually in a loop, to achieve a desired result.
Q14)One iteration of loop is known as:
- Iteration
- Duration
- Cycle
- Integer
Answer:Iteration
Explanation:Iteration refers to the repetition of a process or set of instructions in a computer program, usually in a loop, to achieve a desired result.
Q15) In which loop, statement terminator is a part of its syntax?
- Do- while
- While
- For
- For- each
Answer: Do- while
Explanation: The do-while loop includes the statement terminator as part of its syntax. In this loop, the block of code is executed first, and then the condition is checked. If the condition is true, the block of code is executed again, and the process repeats until the condition becomes false. The syntax for a do-while loop is as follows:
Q16) Which of the following is a loop statement?
- While
- if
- If-else
- Nested if
Answer:While
Explanation:While
Q17) Select the programming structure that executes program statements in order:
- Iteration
- Decision
- Repetition
- Sequence
Answer:Sequence
Explanation:In computer programming, the sequence structure refers to a control structure that executes a series of statements in the order they appear, one after the other, without any branching or decision-making.
Q18) Select the programming structure that executes program statements in a specific order:
- Decision
- Repetition
- Secuence
- Iteration
Answer:Secuence
Explanation:In computer programming, the sequence structure refers to a control structure that executes a series of statements in the order they appear, one after the other, without any branching or decision-making.
Q19) While Loop is also called:
- Conditional loop
- For loop
- Do - while loop
- All of these
Answer:Conditional loop
Explanation:Conditional loop Or While Loop is also called Pre-Test Loop, as the loop condition is checked before executing the loop body.
Q20) In while loop, the loop control variable is always initialized?
- Outside the program
- Inside the loop body
- Outside the body of Loop
- After loop ends
Answer: Outside the body of Loop
Explanation: Outside the body of Loop
Q21) Iterates at least once if condition is false:
- For loop
- Do-while loop
- While loop
- All of these
Answer: Do-while loop
Explanation:The do-while loop iterates at least once, even if the condition is false. In a do-while loop, the loop body is executed first, and then the condition is checked. If the condition is false, the loop will still execute once before terminating.
Q22) The do-while loop structure always ends with:
- Semi coton
- Brace
- Colon
- Comma
Answer:Brace
Explanation:Brace
Q23) Loop structure always executes at least once.
- Nested
- While
- Do-while
- FOR
Answer:Do-while
Explanation:The do-while loop iterates at least once, even if the condition is false. In a do-while loop, the loop body is executed first, and then the condition is checked. If the condition is false, the loop will still execute once before terminating.
Q24) In which loop the condition comes after the body of the loop?
- For ()
- While ()
- Do-while ()
- Nested for ()
Answer: Do-while ()
Explanation: Do-while ()
Q25) In for statement, the expression is executed only once
- Validation
- Test
- Itialization
- Condition
Answer:Itialization
Explanation: In the for loop, the initialization expression is executed only once at the beginning of the loop.
Q26) Which is a loop stunt?
- If
- If else
- Switch
- For
Answer:Switch
Explanation:Switch
Q27) What will be the final value of b after executing the code:
(b =2; b < 7 ; b++):
- 9
- 8
- 1
- 2
Answer:7
Explanation:In the loop, b starts with 2, and in each iteration, it is incremented by 1 until it becomes 7. Once b is 7, the loop condition b < 7 is false, and the loop terminates, leaving the final value of b equal to 7.
Q28) Number of expression in for statement Or
- 3
- 5
- 4
- 2
Answer:3
Explanation:In C language, there are three expressions in the for statement: initialization expression, condition expression, and increment/decrement expression.
Q29) A Loop Counter can be defined as:
- The final Value of a Loop
- The initial Value of a Loop
- The variable that contains loop iteration
- The stop Value of a Loop
Answer: The variable that contains loop iteration
Explanation: A loop counter is a variable used in a loop to keep track of the number of iterations or loops that have been executed. It is typically initialized before the loop begins and then incremented or decremented with each iteration of the loop.
Q30) What is the final value of x after executing the code:
for (int x = 0; x < 10; x++)
- 8
- 09
- 10
- 11
Answer:10
Explanation:The final value of x would be 10. This is because the loop starts with x = 0 and iterates until x is less than 10. When x reaches 10, the condition x < 10 is no longer true and the loop terminates, leaving the final value of x as 10.
Q31) Which of the following loop is called counter loop?
- For
- While
- Do-While
- None
Answer:For
Explanation:All types of loops can be used as counter loops, but the for loop is commonly referred to as a counter loop.
0 Comments