Pages

Tuesday, 23 June 2015

Count Number of Digits

C Program to Count Number of Digits of an Integer

Coding:

#include<stdio.h>
int main()
{
int n,d=0;
printf("Please enter the number:");
scanf("%d",&n);
while(n>0)
{
n=n/10;
d++;
}
printf("Total digit is=%d",d);
return 0;
}

Output:
Please enter the number:165
Total digit is=3