Tuesday, 17 June 2014

C++ programs to find number of digits in a number


Here is a C++ programs to find number of digits in a number


 SOURCE CODE OUTPUT
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int n=0,num;
    cout<<"Enter the number ";
    cin>>num;
    while(num)
    {
       num/=10;
       n++;
    }
    cout<<"Number of digit = "<<n;
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment