Skip to main content

Write a program to reverse all the digits of a given integer.

Write a program to reverse all the digits of a given integer.



import java.util.Scanner; 
class assignment1{ 
public static void main(String[] args) { 
Scanner sc = new Scanner(System.in); 
System.out.println("Enter the number : "); 
int n = sc.nextInt(); 
reverseNum(n); 
sc.close(); 
public static void reverseNum(int num) { 
int n = num; 
int rev = 0; 
while (n > 0) { 
int rem = n % 10; 
rev = rev * 10 + rem; 
n /= 10; 
System.out.println("Reverse of " + num + " is " + rev); 
}


OUTPUT:

Enter the number :
1234
Reverse of 1234 is 4321


Comments

Popular posts from this blog

Computer Full Forms

COMPUTER - full form or meaning is :  Common Operating Machine Purposely Used for Technological and Educational Research. COMPUTER ABBREVIATIONS CPU - Central Processing Unit RAM - Random Access Memory ROM - Read Only Memory PROM - Programmable Read Only Memory EPROM - Erasable PROM EEPROM - Electrically EPROM HDD - Hard Disk Drive FDD - Floppy Disk Drive KBD - KeyBoard I/O - Input & Output CD - Compact Disk DVD - Digital Video Disk SMPS - Switch Mode Power Supply POST - Power ON Self Test BIOS - Basic Input Output System VDU - Visible Display Unit LED - Light Embedded Diode LCD - Liquid Crystal Display USB - Universal Serial Bus VGA - Video/Visual Graphic Adapter LAN - Local Area Network WAN - Wide Area Network MAN - Metropolitan Area Network HLL - High-Level Language LLL - Low-Level Language MIPS - Million of Instruction Per Second Mbps - Mega Bytes Per second Kbps - Kilo Bytes per second HTTP - Hyper Text Templates WWW - World Wide Web IP - Int...

Colors in CSS

Ways to declare Colors in CSS (Image by - Sharma Guides | Subham232330) 1. Color Name 2. Hex Value 3. RGB() and RGBA() 4. HSL() and HSLA() 5. HWB() * Color Name:- background-color:red; * HEX Value:- background-color:#001122; * RGB():- background-color:rgb(25,31,52); * RGBA():- background-color:rgba(0,0,0,1.5);          |           Transparency The hexadecimal system uses values from 0 to 255 but in RGB we can use 0% to 100% as well.

SQL Injection

SQL Injection The SQL Injection is a code penetration technique that might cause loss to our database. It is one of the most practiced web hacking techniques to place malicious code in SQL statements, via webpage input. SQL injection can be used to manipulate the application's web server by malicious users. SQL injection generally occurs when we ask a user to input their username/userID. Instead of a name or ID, the user gives us an SQL statement that we will unknowingly run on our database. For Example - we create a SELECT statement by adding a variable "demoUserID" to select a string. The variable will be fetched from user input (getRequestString). demoUserI = getrequestString("UserId"); demoSQL = "SELECT * FROM users WHERE UserId =" +demoUserId; Types of SQL injection attacks SQL injections can do more harm other than passing the login algorithms. Some of the SQL injection attacks include: Updating, deleting, and inserting the data: An attack can mo...