Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q-2: Write a program in Assembly language using MIPS instruction set that reads two integer numbers from the user named as start and end and

image text in transcribed Q-2: Write a program in Assembly language using MIPS instruction set that reads two integer numbers from the user named as start and end and finds out all the prime numbers between start and end (including start and end). Your program should do the validation of both the numbers as follows: i. start number must be smaller or equal to the end number. ii. Both numbers must be positive. iii. The maximum value for the end number is 2000 . Your program should show appropriate error messages if the value of start OR end is not valid and keep asking the user for the valid numbers. A number is a Prime number if it is divisible only by itself and 1 . For example: 5,13,17,19,29 all are prime numbers. To check whether a number is a prime number, first try dividing it by 2 , and see if you get a remainder equal to 0 . If you do, it can't be a prime number. If you don't get a remainder equal to 0 , next try dividing it by all odd numbers: 3, 5, 7, 9, 11 ... so on until you check up to the sqrt of the number itself. If none of the numbers you tried give you a remainder equal to 0 , then the number is prime. Sample Input / Output: Enter the start number: 100 Enter the end number: 50 Start number must be smaller or equal to the end number. Enter the start number: - 100 Enter the end number: 500 Both the numbers must be positive. Enter the start number: 150 Enter the end number: 250 Prime numbers = 151, 157, 163 ,167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241 Sample Input / Output: Enter the start number: 1000 Enter the end number: 12000 Maximum value for end number is 2000 . Enter the start number: 1600 Enter the end number: 1700 Prime numbers =1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions