Reverse a Number

· unclassifiedUnclassified

Reverse a Number

javamay contain transcription errors
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int rev = 0;
while(n != 0){
rev = rev * 10 + n % 10;
n /= 10;
}
System.out.println(rev);
}
}
← Remove Specific Character from StringReverse a String Without Built-In Functions →
Report an issue with this question