Write a program in QBasic to swap the values of two given numbers without using a third variable.
My teacher gave me a question: write a program in QBasic to swap the values of two given numbers without using a third variable.
Now, my question is not to answer the question, but to explain how this happens. Remember, whoever gives a good answer will be marked as the Brainliest. No hurries! I don't need it immediately!
This is the program you need to explain me:
10 Cls
20 Input " FIRST NUMBER = "; A
30 Input " SECOND NUMBER = "; B
40 A = A + B
50 B = A - B
60 A = A - B
70 Print " THE VALUE OF A IS "; A
80 Print " THE VALUE OF B IS "; B
End
Answers
Answered by
2
STEP 1: START
STEP 2: ENTER x, y
STEP 3: PRINT x, y
STEP 4: x = x + y
STEP 5: y= x - y
STEP 6: x =x - y
STEP 7: PRINT x, y
STEP 8: END
Similar questions