Question: Objective. Use an if() statement, along with a loop, to determine if a number is prime or not. Background Prime numbers are whole numbers that

Objective.

Use an if() statement, along with a loop, to determine if a number is prime or not. Background Prime numbers are whole numbers that can be factored only by the number 1 and itself. Prime numbers are used in cybersecurity, among other fields in computers and engineering.

Assignment

1. Write a function (e.g., isPrime() ) to determine if a given number is prime or not. Your function should take one int parameter and return an int. The value returned should be zero if the number is not prime and one if the number is prime.

2. In main(), test your function by calling it with the following numbers and print to the screen whether each of them is prime or not. Dont put the printf() in your isPrime() function, be sure to put it in main() (hint: youll need an if() statement in main() also).

a. 17 b. 39 c. 49 d. 67 e. 127

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!