1. Question:What is the difference between while and do-while loop? 

    Answer
    While loop: 1. Initialization->condition->statement/increment is the sequence of while loop execution. 
    2. The while loop begins with a termination condition and keeps looping until the termination condition is met.
    3. If the condition is not true, none statement will execute within the loop because condition is checked before executing the statement.

    Do-while loop: 1. Initialization->statement/interment->condition is the sequence of do-while loop execution.
    2. Unlike the while loop, the do-while loop always executes statements in the loop in the first iteration of the loop.
    3. As the condition is checked after executing statements in the loop, at least once loop statements will be executed within the loop even if condition is false.

    1. Report
  2. Question:What is the function of break and continue statement? 

    Answer
    Break: "break" statement is used to exit from loop and selection structure. break statement is widely used in switch-case and loop.
    continue:

    Continue: The "continue" statement tells the interpreter to immediately start the next iteration of the loop and skip remaining code block.

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd