Write a QBASIC program to exchange the values of two variables using a third variable
Answers
Answered by
2
Answer:
Swapping program using third variable in Qbasic:
Output:
ENTER THE FIRST NUMBER: 12
ENTER THE SECOND NUMBER: 2
BEFORE INTERCHANGE NUMBER ARE: 12 2
AFTER INTERCHANGE NUMBER ARE: 2 12
Explanation:
Explanation:
The Qbasic swapping program to this question can be given as follows:
Program:
CLS
INPUT "ENTER THE FIRST NUMBER: ", A 'input number'
INPUT "ENTER THE SECOND NUMBER: ", B 'input number'
PRINT "BEFORE INTERCHANGE NUMBER ARE: ", A, B 'print value before swapping'
SWAP=0 'defining variable swap'
'perform swapping'
SWAP=A
A=B
B=SWAP
PRINT "AFTER INTERCHANGE NUMBER ARE: ", A,B 'print value after swapping'
END
Similar questions