ICSE
Class 10
Write a function that interchanges the value of two integers A and B without using any extra variable.
Answers
Answered by
1
import java.util.*;
class exchange
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("enter 2 integers");
int a=sc.nextInt();
int b=sc.nextInt();
int i;
for(i=a;i is less than equal to a;I++)
{
b=a;
i=b;
}
System.out.println(a);
System.out.println(b);
}
}
I can't find the symbol of less than so
parthomsarwade:
but i is for for loop
Answered by
2
Answer:
class prog{
void main(int a,int b)
{
a=a+b;
b=a-b;
a=a-b;
System.out.println(a+" "+b);
}
}
i haven't used any extra variable like the other who has answered.
please mark it as the brainliest answer.
Similar questions
Economy,
6 months ago
Math,
6 months ago
Science,
6 months ago
India Languages,
1 year ago
English,
1 year ago