C program to count the digit in a given number.

 

01 #include<stdio.h>
02
03 int main()
04 {
05 int num,count=0;
06 printf("Enter a number: ");
07 scanf("%d",&num);
08
09 while(num)
10 {
11 num=num/10;
12 count++;
13 }
14 printf("Total digits is: %d",count);
15 return 0;
16 }
 
 
OUTPUT :

Enter a number: 12446
Total digits is : 5

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.