Write a Program to reverse the number using algorithm
import java.util.Scanner;
public class AlgoReverse {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int no;
System.out.print("Please Enter the number \t");
no = sc.nextInt();
int rev = 0;
while(no != 0){
rev = rev*10 + no%10;
no/=10;
}
System.out.println("Reverse Number : " + rev);
sc.close();
}
}
Output of program :
Comments
Post a Comment