Computer Science, asked by padipsharma1, 23 days ago

Write a program in OBasic accept value of two numbers and interchange their value​

Answers

Answered by anindyaadhikari13
2

Answer:

This is the required QBASIC program for the question.

1 CLS

2 INPUT "Enter a:"; A

3 INPUT "Enter b:"; B

4 PRINT "Before Swapping,"

5 PRINT "a: "; A

6 PRINT "b: "; B

7 C = A

8 A = B

9 B = C

10 PRINT "After Swapping,"

11 PRINT "a: "; A

12 PRINT "b: "; B

13 END

Explanation:

  • The values are interchanged using third variable. We will store the first number in third variable. Now, we will assign the value of the second variable in the first variable. So, a becomes b. Now, original value of a is erased. But that value is stored earlier in third variable. So, we will initialise the value of the third variable. So, b becomes a. After swapping, values are displayed on the screen.
Attachments:
Similar questions