How to count number in C language ?
For example , I have have input 5 until 7
then it will print 3
or input 2 until 4
then it will print 3
here my code:
#include <stdio.h>
int main()
{
int n,count=0;
printf("Enter an integer: ");
scanf("%d", &n);
while(n!=0)
{
n/=10; /* n=n/10 */
++count;
}
printf("Number of digits: %d",count);
}
there is wrong, because i can only put one value .. please help