Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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