c program to print the number of digits in a decimal number

#include
int main()
{
int n,count=0,x;
printf("ENter the decimal number\n");
scanf("%d",&n);
x=n;
while(n>0)
{
count++;
n=n/10;
}
printf("Number %d has %d digits\n",x,count);
}






output
ENter the decimal number
2345
Number 2345 has 4 digits

No comments:

Post a Comment