Search

Count the number of digits in C || C Programs

Code -

#include <stdio.h> 
int main()  
{  
 int n;  // variable declaration 
 int count=0;   // variable declaration 
   printf("Enter a number");  
   scanf("%d",&n);  
 while(n!=0)  
   {  
       n=n/10;  
       count++;  
   }  
 
   printf("\nThe number of digits in an integer is : %d",count);  
 return 0;  
}  

Output -

Enter the number 99000
No. of Integers 5

1 view0 comments

Related Posts

See All

Program of Random Number in C || C Programs

Code - #include <stdio.h> #include <conio.h> #include <stdlib.h> void main() { // use rand() function to generate the number printf (" The random number is: %d", rand()); pri

Getchar() function in C || C Programs

Code - #include <stdio.h> #include <conio.h> void main() { char c; printf ("\n Enter a character \n"); c = getchar(); // get a single character printf(" You have passed ")

  • 1024px-Telegram_logo.svg
  • download
  • YouTube