Dain1234 / Java-Programming

0 stars 0 forks source link

Reverse number #23

Open Dain1234 opened 1 year ago

Dain1234 commented 1 year ago

package com.dain.logics;

import java.util.Scanner;

public class Reversenumber {

public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter the number:");

    int num = sc.nextInt();
    int rev = 0;

    for (int i = 1; i <= num; i++) {
        int rem = num % 10;
        num = num / 10;
        rev = rev * 10 + rem;
    }

    System.out.println(rev);

}

}