If have a problem in solving this & i googled but cudn't find ne solution...
if integer a = 12345. write a program (without using any in-built function) in C++/C# or
VB.NET. to find the length of integer a (obviously in this case it is 5).remember if its array then its simple.but its an integer datatype.
pls solve my problem?
__________________
I'm the One you've been Waiting for...
Advertisements. Register and be a member of the community to get rid of them.
int a=12345;
int count = 0;
while(a !=0 )
{
a = a/10; //removes the last digit of the number; or better a /= 10
count++;
}
after the loop is executed a will be zero count will contain the number of digits in the number. if you want back a just use int b = a; //before the loop a =b; //and after the loop
__________________
At times life takes a U turn and you get back where you were...
Last edited by Vishal Patil; 06-09-2009 at 06:45 PM.