Given here is an algorithm to swap two numbers. Which of the following line will replace'?" to complete the algorithm? Step 1: Read two numbers X and Y. Step 2: ? Step 3: Y=X−Y Step 4: X=X−Y
A
X=X+Y
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
X=X×Y
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
X=XY
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
X=X−Y
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution
The correct option is AX=X+Y Suppose value of X=10 and Y=20 X=X+Y→X=10+20=30 Y=X−Y→Y=30−20=10 X=X−Y→X=30−10=20 Now X=20 and Y=10.