It is a kind of iterative control statement, where the provided condition runs until the condition is satisfied.
/* Program 5
Date : 20-03-2019
Program Name: Calculate number of digits
Developed By: Aditi B
*/
#include <iostream>
using namespace std;
int main()
{
int num, count;
cout<<"Enter any number:\t";
cin>>num;
//Run the loop till the number is greater than 0
while(num != 0)
{
count ++; //increment the count
num = num /10; //remove the last digit of the number
}
cout<< "Total number of digits in given number is "<<count;
return 0;
}
Output