Computer Science, asked by anjanachaudharyfeb, 12 days ago

wap to input 2 digit number and swap the 1 and the last digits without using 3 variable​

Answers

Answered by ashutoshvikram17
1

Answer:

Explanation:

import java.util.*;  

class Swap    

{  

   public static void main(String a[])    

   {    

       System.out.println("Enter the value of x and y");  

       Scanner sc = new Scanner(System.in);  

       /*Define variables*/  

       int x = sc.nextInt();  

       int y = sc.nextInt();  

       System.out.println("before swapping numbers: "+x +" "+ y);  

      /*Swapping*/  

       x = x + y;    

       y = x - y;    

       x = x - y;    

       System.out.println("After swapping: "+x +"  " + y);    

   }    

}  

Similar questions