In: Computer Science
C programming.
Explain by taking a programming example how do while loop is different from while loop?
While Loop Example
Here is a simple example of how a while loop works.This program prints numbers from 1 to 10 without actually using the ten printf statements but a while loop.
Here, the ā\nā in the printf call is used to move to the next line.
Its output should look something like this-
DO-WHILE LOOP
Do-While Loop Example
Here is a simple example to find the sum of 1 to 10 using the do-while loop.
Its output should be something like this-
Difference Between while and do while loop
While Loop
DO WHILE LOOP