# Count number of Digits of an Integer in C++

## C++ Program to Find number of Digits from any number

Any number is a combination of digits, like 342 have three digits and 4325 have four digits. For calculating the digits of any number user have three possibilities to input values.

• Enter +ve numbers
• Enter -ve numbers
• Enter zero

## Example

```#include<iostream.h>
#include<conio.h>

void main()
{
int no,a=0;
clrscr();
cout<<"Enter any num : ";
cin>>no;
while(no>0)
{
no=no/10;
a++;
}
cout<<"\n no. of digits in given number is: "<<a;
getch();
}
```

## Output

```Enter any num : 650
no. of digits in given number is : 3
```

## C++ program to count number of digits of an integer

```#include<iostream.h>
#include<conio.h>

void main()
{
int no,a=0;
clrscr();
cout<<"Enter any num : ";
cin>>no;
if(no<0)
{
no=no * -1;
}
else if(no==0)
{
no=1;
}
while(no>0)
{
no=no/10;
a++;
}
cout<<"\n no. of digits in given number is: "<<a;
getch();
}
```

## Output

```Enter any num : -650
no. of digits in given number is : 3
```