QUOTE(AmitTheInfinity @ 26 Jun, 2008 - 06:07 AM)

QUOTE(junaidjee @ 26 Jun, 2008 - 06:28 PM)

Suppose i have a five digit number. How can i convert this number so that this number is divided into five parts and then separated by three blank spaces.
Suppose i have a number 12345 then i want output like that 1 2 3 4 5
use mod 10 div 10 method.
java
int i=12345,rem;
while(i>0)
{
rem = i % 10;
i /=10;
System.out.print(rem);
System.out.print(" ");
}
I hope this will help you.

This will print the digits in reverse order
CODE
int i = 12345;
String str = "" + i; // convert to String
char[] digit = str.toCharArray(); // String into array of char
for(int i = 0; i < digit.length; i++)
System.out.print(digit[i] + " ");
System.out.println();
This post has been edited by pbl: 28 Jun, 2008 - 06:16 AM