Write a program that clears the screen, locates the cursor, prompts the user for
ID: 3819867 • Letter: W
Question
Write a program that clears the screen, locates the cursor, prompts the user for two numbers, adds the numbers, and displays their sum. Use the Clrscr, Gotoxy, Writestring, Readint, and Writeint procedures from the link library. Define one array of 8-bit values and another of 16-bit values. Use the OFFSET operator to load the address of various numbers into BX, and write each of the standard output. Using the Random range procedure from the link library, generate 20 pseudorandom numbers in the range 0-100. Store the numbers in an array variable and display the numbers. Using array 1 from the previous exercise, write a program that inserts 2500h in position 3. The program must shift all subsequent numbers two bytes higher in memory to make room for the inserted number. Create a sequentially numbered array of 50 integers. Then use the Random_range procedure to shuffle the array in a random order. (Each number will only appear once in the array.) Display the shuffled array.Explanation / Answer
Answer:
input1stIntMsg BYTE "Input the 1st integer: ",0
input2ndIntMsg BYTE "Input the 2nd integer: ",0
outputSumMsg BYTE "The sum of the two integers: ",0
num1 DWORD ?
num2 DWORD ?
sum DWORD ?
.code
main PROC
call Clrscr ; clear screen
; read the first number
mov dl, 20 ; set the column
mov dh, 11 ; set the row
call Gotoxy ; move the cursor to near the center
; output the prompt message
mov edx,OFFSET input1stIntMsg
call WriteString
call ReadInt ; read integer
mov num1, eax ; store the value
; read the second number
mov dl, 20 ; set the column
mov dh, 12 ; set the row
call Gotoxy ; move the cursor to near the center
; output the prompt message
mov edx,OFFSET input2ndIntMsg
call WriteString
call ReadInt ; read integer
mov num2, eax ; store the value
; compute the sum
mov eax, num2
add eax, num1
mov sum, eax
; output result
mov dl, 20 ; set the column
mov dh, 13 ; set the row
call Gotoxy ; move the cursor to near the center
mov edx, OFFSET outputSumMsg
call WriteString
mov eax, sum
call WriteInt
exit
main ENDP
END main
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.