Computer Science, asked by indraneel14, 2 months ago

The value of a is 34 and the value of b is 79. Write a JAVA 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​

Answers

Answered by waraafghan
2
public class swap
{
public static void main(String args[])
{
int a,b;
a=34;
b=79;

//Before Swapping
System.out.println(“A = “+a+” B= “+b);

int temp;
temp=a;
a=b;
b=a;

// After Swapping

System.out.println(“A = “+a+” B= “+b);
}
}
Similar questions