Find number of digit in given integer by R4R Team

Example-
Number is 3245
Number of digits is 4.
Number is 9087245
Number of digits is 7


program-

#include < stdio.h>
int main()
{
int n,count=0;
printf("Enter number\n");
scanf("%d",&n);
while(n)
{
count++;
n=n/10;
}
printf("Number of digit in number is %d",count);
return 0;
}


output-

Enter number
34400
Number of digit in number is 5

-In this program, we take a input of the integer number, and for each digit we run the while loop and increase the value of count by (count++) and after loop we have a number of digits in count variable so we print that.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!