Examples of do while loops in c++ Programming

0

Do-while loops are variant of while loops

▸ This loop will execute the code block once, before checking if the condition is

true, then it will repeat the loop as long as the condition is true.

Example :

do 

   {

// code to add

   }

while ( condition ) 

All Contributions

How to Write a program to display numbers from 1 to 5 using do-while loop :

#include <iostream>
using namespace std ;
Int main ()
{
      int i = 1 ;
      do
	   {
		cout << i << endl ;
		i++ ;
	   }
      while ( i <= 5 ) ;
} 

 

total contributions (1)

New to examplegeek.com?

Join us