Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

Print the reverse of number

Article:
Viewed:  934 
Posted On:  24/07/2013 04:01:23 
Hi all,With the help of this article i am going to tell you that how we can find out the reverse of the number given by the user ...... 

 

Below is my code:


import java.util.Scanner;
class reverse
{
public static void main(String s[])
{
int a,b,c=0;
System.out.println("enter  no. ");
Scanner scan=new Scanner(System.in);
a=scan.nextInt();
System.out.println("you entered ="+a);
while(a!=0)
{
b=a%10;
c=c*10+b;
a=a/10;
}
System.out.println("reverse no is "+c);
 }
}

  Step 1:
  After writing this in notepad save the file with the name followed by (.java) for eg. I saved it with reverse.java

 Step 2 : 
Open command prompt 

 Step 3 : 
Write javac reverse.java - Press Enter for compilation

 Step 4 : 
Write java reverse for execution

Output:

Reverse.png

Image 1.

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us