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
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