Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
184 views

Reverse Number (JAVA PROGRAM PDF

JAVA PROGRAM TO FIND THE REVERSE OF A NUMBER. WITH COMMENTS AND DETAILS TO HELP YOU UNDERSTAND THEM.THIS PROGRAM HAS BEEN RUN ON BlueJ AND IS ERROR FREE.IT WILL SURELY HELP YOU IN STUDYING JAVA PROGRAMS FOR EXAMS OR OTHERWISE.

Uploaded by

AMRENDRA SINGH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
184 views

Reverse Number (JAVA PROGRAM PDF

JAVA PROGRAM TO FIND THE REVERSE OF A NUMBER. WITH COMMENTS AND DETAILS TO HELP YOU UNDERSTAND THEM.THIS PROGRAM HAS BEEN RUN ON BlueJ AND IS ERROR FREE.IT WILL SURELY HELP YOU IN STUDYING JAVA PROGRAMS FOR EXAMS OR OTHERWISE.

Uploaded by

AMRENDRA SINGH
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Class reverse 1/1

/*
* ashking13th@gmail.com
* javaprogramsbyashking13th.blogspot.in
* ashkingjava.blogspot.in
*
* QUESTION
*
* Design a program in java to find the reverse of a number.
* eg if
* input 123 then
* output should be 321
*/
import java.io.*;
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
}
System.out.println("original number\t"+n);
System.out.println("reverse number\t"+s);
}
}
Mar 25, 2014 3:23:43 PM

You might also like