Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

arkapg211002 

/
SEM-5-CSE

Code Issues Pull requests Discussions Actions Projects Wiki Security Insights

SEM-5-CSE / OOPS (PCC-CS593) / All Assignments / Unit 2. Constructor, Data Types and Control Flows
/ (2023) Lab Assignment LA2.1 - Control Flows
/ RevNum.java

arkapg211002 5 days ago

33 lines (26 loc) · 637 Bytes

Code Blame

1 /**
2 Write a Java program to input a number and display the reverse of that number.
3
4 Input
5 173
6
7 Result
8 371
9
10 */
11
12 import java.util.Scanner;
13 public class RevNum {
14 public static void main(String args[]) {
15 Scanner sc = new Scanner(System.in);
16 int n = sc.nextInt();
17
18 int s = 0;
19 int rem;
20 /* Shape up the logic */
21 /* Hints: Calculate remainder over 10 */
22 /* Progressively divide by 10 until n value is 0 */
23
24 while(n>0)
25 {
26 rem=n%10;
27 s=(s*10)+rem;
28 n/=10;
29 }
30 System.out.println( s );
31
32 }
33 }

You might also like