Examples of while loops in c++ Programming

0

While loops is Used when the number of iterations isn’t know, but the condition is clear

Example :

While ( condition)

{

    // code to add

All Contributions

How to Write a program that reverse a number (example: 4392 => 2934) :

#include <iostream>
using namespace std ;
int main()
{
      int x ;
      cout << " Enter a number : " ;
      cin >> x ;
      while ( x > 0) ;
      {
	   cout << x % 10 ;
	   x = x / 10 ;
      }
          return 0 ;
} 

Write c++ program to print “Hello” ten times using while loop

#include 
using namespace std ;
int main()
{
      int i = 0 ;
      while ( i < 10)
      {
            Cout << " hello"  << endl;
      }
	    return 0 ;
} 

total contributions (2)

New to examplegeek.com?

Join us