C Program to Count the number of digits given in an number:This program is count the number of digits in a given number.
in which we take an number as input from user and count the number of digits exist in the that number
For Example:
If we take the number(12893) as input from user and count the total number of digits in the number. there are five digits in the number.
ALGORITHM:-
step 1 : Start
step 2 : Enter any integer number
step 3 : Now we divide the number by 10 and increase the counter value
step 4 : Repeat the step 3 until number is none zero
step 5 : Stop
PROGRAM CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int num,count=0;
printf("Enter a number: ");
scanf("%d", &num);
while(num)
{
num = num / 10;
count++;
}
printf("Total digits is: %d", count);
getch();
}
OUTPUT:-
Enter the any integer number: 1284
total digits is: 4
C Program to count the total number of digits in given number how to count the total number of digits in number count the digits in number
ConversionConversion EmoticonEmoticon