-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverseOfANumber.java
More file actions
41 lines (38 loc) · 942 Bytes
/
ReverseOfANumber.java
File metadata and controls
41 lines (38 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Problem
// Result
// Reverse of a number
// Send Feedback
// Write a program to generate the reverse of a given number N. Print the corresponding reverse number.
// Note : If a number has trailing zeros, then its reverse will not include them. For e.g., reverse of 10400 will be 401 instead of 00401.
// Input format :
// Integer N
// Output format :
// Corresponding reverse number
// Constraints:
// 0 <= N < 10^8
// Sample Input 1 :
// 1234
// Sample Output 1 :
// 4321
// Sample Input 2 :
// 1980
// Sample Output 2 :
// 891
import java.util.Scanner;
/**
* ReverseOfANumber
*/
public class ReverseOfANumber {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int ans = 0;
while (n != 0) {
int rem = n % 10;
ans = ans * 10 + rem;
n = n / 10;
}
System.out.println(ans);
s.close();
}
}