While loops is Used when the number of iterations isn’t know, but the condition is clear
Example :
While ( condition)
{
// code to add
}
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)
How to Write a program that reverse a number (example: 4392 => 2934) :