Computer Science, asked by indraneel14, 4 hours ago

The value of a is 34 and the value of b is 79. Write a program to interchange the value of a and b. display the variables BEFORE INTERCHANGE AND AFTER INTERCHANGE. Ex:
Before interchange a=34 b= 79
After interchange a=79 b=34

Write JAVA programs to calculate the above. DO NOT USE ANY INPUT METHOD FOR ANY OF THE ABOVE PROGRAMS.​

Answers

Answered by vj98976
1

Answer:

import java.util.*;  

class Swap{  

   public static void main(String[] args) {  

      int a, b, t;  

      a=34;

b=79;

      System.out.println("before swapping numbers: "+a +"  "+ b);  

      /*swapping */  

      t = a;  

      a = b;  

      b = t;  

      System.out.println("After swapping: "+a +"   " + b);  

      System.out.println( );  

   }    

}  

Explanation:

Similar questions