Lab 7 Problem Solution

$30.00 $24.00

An integer is said to be **prime** if it’s divisible by only 1 and itself. – For example, 2, 3, 5 and 7 are prime, but 4, 6, 8 and 9 are not. Write the program that prints all the primes within the user specified range. 1. Define a function `isprime` that determines whether a…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

An integer is said to be **prime** if it’s divisible by only 1 and itself.

– For example, 2, 3, 5 and 7 are prime, but 4, 6, 8 and 9 are not.

Write the program that prints all the primes within the user specified range.

1. Define a function `isprime` that determines whether a integer number is prime or not.

– *Hint:* How many of these numbers do you really have to test before being sure that you’ve found all the primes?

2. Use this function in a program that determines and prints all the prime numbers in the user specified range.

– Prompt user to enter upper bound of the range, `maxnum`

– Using function `isprime` check & print all the prime numbers within the range: `[2, maxnum]`

Lab 7 Problem Solution
$30.00 $24.00