Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ / TODO: include proper headers here #include #include / / what header is needed for square root function ? ? / / #include /
TODO: include proper headers here
#include
#include
what header is needed for square root function
#include
TODO: complete prime tester function
to generate desired output.
bool isPrime int number
TODO: complete the condition here
guard negative numbers, and as they are not considered as prime numbers.
if CONDITION
return false;
TODO: complete the for loop to test all possible factors
possible factors starts from inclusive and goes all the way to sqrtninclusive
for LOOP
if if evenly divisible by factor, then not a prime number
return false;
no factor found, return true
return true;
question :
TA may give general guidelines but will not help on code level.
develop a function to return the st prime number.
correct answer:
int thePrimeNumber
TODO: please finish the main function.
int main
question s main function requirement:
generate following output by using isPrime function:
is NOT a prime number.
is a prime number.
is a prime number.
is NOT a prime number.
is a prime number.
is NOT a prime number.
is a prime number.
is NOT a prime number.
is NOT a prime number.
is NOT a prime number.
is a prime number.
is NOT a prime number.
is a prime number.
is NOT a prime number.
is NOT a prime number.
is NOT a prime number.
is a prime number.
is NOT a prime number.
is a prime number.
question s code.
Please complete the function thePrimeNumber first,
then uncomment following code to generate desired output
std::cout "The st prime number: thePrimeNumber std::endl;
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