Write a program to input any two integer numbers and interchange the values using a third variable.
Home
/
Computer Science
/
Write a program to input any two integer numbers and interchange the values using a third variable.
Write a program to input any two integer numbers and interchange the values using a third variable.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
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);
}
}
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);
}
}