Count Digits in a number-
#include <stdio.h>
int main()
{
int n,count=0;
printf("Enter the number ");
scanf("%d",&n);
while (n>0)
{
n/=10;
++count;
}
printf("%d,",count);
return 0;
}
Output -
Enter the number 1234
4
#include <stdio.h>
int main()
{
int n,count=0;
printf("Enter the number ");
scanf("%d",&n);
while (n>0)
{
n/=10;
++count;
}
printf("%d,",count);
return 0;
}
Enter the number 1234
4
0 Comments