write a program in java unit to input values of two variables using scanner class.exchange the values of the variables before exchange qnd after exchange without using 3rd variable
Answers
Answered by
1
Answer:
X= 25 (First number), Y= 23 (second number)
Swapping Logic:
X = X + Y = 25 +23 = 48
Y = X - Y = 48 - 23 = 25
X = X -Y = 48 - 25 = 23
and the numbers are swapped as X =23
Similar questions
Political Science,
16 days ago
Math,
16 days ago
Chemistry,
16 days ago
Science,
1 month ago
Math,
1 month ago
Chemistry,
9 months ago
Social Sciences,
9 months ago