This is a simple java program which finds the reverse of a given number.
PROGRAM :
OUTPUT :
PROGRAM :
package codingcorner.in; import java.util.Scanner; public class Reverse { public static void main(String[] args) { int number, remainder, reverse = 0, num; Scanner scan = new Scanner(System.in); System.out.print("Enter a number :\t"); number = scan.nextInt(); scan.close(); num = number; while (number != 0) { remainder = number % 10; reverse = reverse * 10 + remainder; number = number / 10; } System.out.println("Reverse of number " + num + " is : \t " + reverse); } }
OUTPUT :
No comments:
Post a Comment