This program takes a number from the user and then using loop, modulo and division operator split the number into digits.
as:
import java.util.Scanner;
class Split_num
{
public static void main ( String [] args)
{
Scanner a = new Scanner (System.in);
int num, n, r;
System.out.print ("Enter a number: ");
num = a. nextInt ();
n = num;
while ( n != 0)
{
r = n % 10;
System.out.print (r);
n = n/10;
}
}
}
But this program prints the splited integers in revers order. I have searched alot in books and on the internet to print the integers in forward order but all in vain. so question is:
what we will do in order to print the integers splited from a number in Forward Oreder?
What we