Computer Science, asked by Raashidhurrah, 1 year ago

what is the difference between while and do-while statement

Answers

Answered by VemugantiRahul
1
Hi there
Here's the answer:

•Both 'while' and 'do-while' are iteration statements.(That are repeatedly executed until a condition is satisfied).
•'While' and 'do-while' are also called as 'Looping statements'

<><><> ¶ while ¶<><><>
while statement will be repeatedly executed as long as expression remainder true.

•Syntax:

while(exp)
{
body of loop
}

•••When 'while' is reached, exp (expression) is evaluated.
°If it is found to be false, body of loop will not be executed and loop terminates.
°Otherwise, the body of the loop will be executed till it becomes false.

<><><> ¶ do-while ¶<><><>
It is similar to 'while' loop except that it(body of loop) is executed atleast once.

•Syntax:
do
{
body of while
} while(exp)

•••Test of expression (for loop repetition) is done after each time body of time is executed.

•°•°•°•°•°<><><><><>°•°•°•°•°•

¶¶ Check Attachment for Flowcharts ¶¶

•°•°•°•°•°<><><><><>°•°•°•°•°•

Hope it helps
:)
Comment if you need to know anything.
Attachments:

VemugantiRahul: my pleasure
Similar questions