Write a program to input any two integer numbers and interchange the values using a third variable.
Answers
Answered by
10
Answer:
class swap
{
void main(int a,int b)
{
int k=a;
a=b;
b=k;
System.out.println("a:"+a);
System.ouy.println("b:"+b);
}
}
Answered by
65
Here is your answer.
class Program
{
static void main(int a, int b)
{
System.out.println("Before Swapping. ");
System.out.println(" a: " + a);
System.out.println(" b: "+ b);
int temp=a;
a=b;
b=temp;
System.out.println(" After Swapping. ");
System.out.println(" a: "+a);
System.out.println(" b: "+b);
}
}
Similar questions