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 DO NOT USE ANY INPUT METHOD
Answers
Answered by
4
Answer:
Program:-
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int a=34,b=79;
System.out.println("Before interchange a="+a+" b="+b);
System.out.println("After interchange a="+b+" b="+a);
in.close();
}
}
- The logic is simple just interchange the values of a and b and print b in place of a and and a in place of b.
Attachments:
Similar questions