Find Length of the number by R4R Team

Example-
Number is 3245
Length is 4.
Number is 9087245
Length is 7

program-

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


output-

Enter Number
1234
Length is 4

Enter Number
543
Length is 3

-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 length 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!