Computer Science, asked by purimamta138, 23 hours ago

write a Qbasic program to print reverse number from 10 to 50 using do while loop .​

Answers

Answered by snamitatiwari
0

Answer:

Number

Let n be the input number.

Declare a variable temp and set temp = n.

Declare a variable num. Set num = 0.

Repeat the following steps while temp > 0

Set r = temp MOD 10. This step stores the rightmost digit of temp in r.

Set num = num * 10 + r. This step adds r at once place of num.

Set temp = temp / 10. This step removes the rightmost digit of temp.

The reverse of N is stored in num.

Reverse a Number in QBasic

CLS

INPUT "Enter a Number: ", n

temp = n

num = 0

WHILE temp > 0

r = temp MOD 10

num = num * 10 + r

' Note: We are using '\' for division instead of '/'

' '\' returns integer number

' whereas '/' returns floating number

temp = temp \ 10

WEND

PRINT "Reverse of"; n; "is: "; num

END

Similar questions