4. (I) Write a program to count the digit in a number

4. (I) Write a program to count the digit in a number
Write a program to count the digit in a number
#include <stdio.h>
int main()
{
long long n;
int count=0;
printf("Enter an integer: ");
scanf("%lld", &n);
while(n!=0)
{
n /= 10; // n = n/10
++count;
}
printf("Number of digits: %d",count);
}
4. (I) Write a program to count the digit in a number 4. (I) Write a program to count the digit in a number Reviewed by admin on December 23, 2019 Rating: 5

No comments:

Powered by Blogger.