Class reverse 1/1
/*
* ashking13th@[Link]
* [Link]
* [Link]
*
* QUESTION
*
* Design a program in java to find the reverse of a number.
* eg if
* input 123 then
* output should be 321
*/
import [Link].*;
public class reverse
{
public void main(int n) throws IOException
//method to create reverse of a number
{
int m=n;
//creating dummy variable
int r=0;
int s=0;
while(m>0)
//loop condition
{
r=m%10;
//last digit extraction
s=(s*10)+r;
//creating reverse number
m=m/10;
//updating loop variable
}
[Link]("original number\t"+n);
[Link]("reverse number\t"+s);
}
}
Mar 25, 2014 [Link] PM