Reversing a Number...
I got lots of error in this one....
Reversing a Number:
import java.util.*;
public class Main
{
//author lok ik
//@opensource
public static void main(String[] args)
{
int b, c=0;int i=0;
Scanner input = new Scanner(System.in);
System.out.println("Enter the number to be reversed???");
int a=input.nextInt();
b=a;
while(a>0)
{
b=a%10;
if(i==0)
{
c=b;
i++;
}
else
{
c=c*10+b;
}
a=a/10;
}
System.out.println("The reversed num is "+c);
}
}
Posted By lol ik
Comments
Post a Comment