C++ do while Loop

Description

C++ do while Loop

#include <iostream> 
  
using namespace std; 
  
int main(int argc, const char * argv[]) 
{ 
        unsigned int array[10]; 
        unsigned int count = 0; 
      //  w ww .ja v a  2s.  c o m
        do 
        { 
            array[count] = count * 2; 
            cout << "Loop Iteration: " << array[count++] << endl; 
        } while (count < 10); 
      
        return 0; 
}
#include <iostream>
using namespace std;
int main()// www .  ja v a  2  s  . c o m
{
   long dividend, divisor;
   char ch;
   do                                   //start of do loop
   {                                 //do some processing
       cout << "Enter dividend: "; cin >> dividend;
       cout << "Enter divisor: ";  cin >> divisor;
       cout << "Quotient is " << dividend / divisor;
       cout << ", remainder is " << dividend % divisor;
       cout << "\nDo another? (y/n): ";  //do it again?
       cin >> ch;
   }
   while( ch != 'n' );                  //loop condition
   return 0;
}



PreviousNext

Related