Created
November 12, 2015 11:10
-
-
Save bragboy/351f876d8714773adfbe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package misc.integers; | |
| public class RevNum { | |
| public static void main(String args[]){ | |
| int sampleNum = 12345678; | |
| System.out.println("Input Num : "+sampleNum); | |
| int reversedNum = 0; | |
| while(sampleNum!=0){ | |
| reversedNum = reversedNum*10 + sampleNum%10; | |
| sampleNum = sampleNum/10; | |
| } | |
| System.out.println("Reversed Num : "+reversedNum); | |
| } | |
| } | |
| //SAMPLE OUTPUT | |
| //Input Num : 12345678 | |
| //Reversed Num : 87654321 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment