Question: Programming Assignment # 5 - - ( Calculate the nth Prime Number ) Due: _ see canvas Name your program: p 5 . c This
Programming Assignment #Calculate the nth Prime Number
Due:see canvas
Name your program: pc
This week we are going to simplify last weeks program with the use of a
Function. The code below is the code shown in class last week. This week we
need to replace the code in the black rectangle with a function called,
checkifprime;
#include
#define TRUE
#define FALSE
function prototype goes here
int main void
unsigned int nthprime, numberofprimes;
unsigned int testint, divisor;
Bool isPrime;
printfEnter the nthprime to find:";
scanfu &nthprime;
numberofprimes ;
testint ;
do
testint;
isPrimeTRUE; assume testint is prime until proven not to be
fordivisor ; divisor testint; divisor
iftestint divisor
isPrime FALSE;
break;
ifisPrime TRUE
numberofprimes;
while numberofprimes nthprime ;
printfThe u Prime Number u
nthprime, testint;
return ;
The function definition should look like:
Bool checkifprime unsigned int testnumber
code to determine if a number is prime, goes here
This function takes an unsigned int as an argument, and returns ie false if
the integer is not prime, and returns for true if the integer is prime.
Once youve completed your program, fill in the table below.
th Prime Number is: th Prime Number is: th Prime Number is:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
