/*
Write a C Program to Count Number of Digits in an Integer.
*/
#include <stdio.h>
int main()
{
long long num;
int count = 0;
/* Input number from user */
printf("Enter any number: ");
scanf("%lld", &num);
/* Run loop till num is greater than 0 */
while(num != 0)
{
/* Increment digit count */
count++;
/* Remove last digit of 'num' */
num /= 10;
}
printf("Total digits: %d", count);
return 0;
}
OUTPUT :
Enter any number: 45698
Total digits: 5
Thank you very much for reading carefully, if you have any other questions, you can share it with us through comments, if this information was important to you, please let us know through comments.
Please do comment and share.
Thank You.
No comments:
Post a Comment