Answer to Question #193421 in C for sai

Question #193421

Write a program which counts for the number of digits in an integer number being

entered by user using:

a. For loop

b. While loop

c. Do while loop


1
Expert's answer
2021-05-14T23:07:18-0400
#include <stdio.h>  
int main()  
{  
   printf("Enter a number : "); 
   int n;  
   int count=0;     
   scanf("%d",&n);  
   while(n>0)  
   {  
       n=n/10;  
       count++;  
   }  
     
   printf("\nThe number of digits in entered number is : %d",count);  
   return 0;  
}  

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS