Recent Posts

Wednesday 11 June 2014

04:11

Reverse any no with Java program

Welcome again dear readers of our blog, Today we will learn how to write a program which can make reverse of any no. using Java language.

I hope you are ready with Eclipse IDE or any other java IDE like Netbeans etc.So lets start................

CODES:

//Copyright @author Harpreet Sandhu 
class revno { 
int rev(int n) {int r=0; 
while(n>0) {
 r=r*10+n%10; n=n/10; }
 return(r); }
 public static void main(String s[])
 { revno z= new revno();
 System.out.println(z.rev(142)); 
}}

OUTPUT:

241

If you face any problem in any program feel free to comment below.

0 comments:

Post a Comment