Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please do this in C++ or assembly language: Write a program that takes a positive number n as input. Then it prints all the numbers
Please do this in C++ or assembly language:
Write a program that takes a positive number n as input. Then it prints all the numbers x below n that have exactly 2 different integral divisors (Besides 1 and n).
For example, 15 is such a number. It is divisible by 1,3,5,15. (Here 3 and 5 are the two different divisors, besides 1 and 15).
However, 4 is not such a number. It is divisible by 1,2,4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If the user enters a negative number, you must display a message that you expect a positive number and you run the program again till the user enters a positive number.
You need to have a procedure called is2divisors. You may have more procedures if you like.
This procedure receives a number through one of the registers.
Check if this number has exactly 2 different integral divisors (Besides 1 and x).
Returns back (through one of the registers) to main program 1, if the number has exactly 2 different integral divisors (Besides 1 and x), 0 otherwise.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global variables are allowed only inside main proc. It is ok to pass the values to your program through registers.
You must reserve any register you use inside your procedures, except the one you are returning to main.
You are not allowed to use "uses" and "pushAD" operator
Sample run:
enter a number: 16
All the numbers below your number that have exactly
2 different integral divisors (Besides 1 and the number) are: +6 +8 +10 +14 +15
Press any key to continue . . .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started