Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a) Write a function that determines whether a number isprime. b) Use this functi

ID: 3608181 • Letter: A

Question

a) Write a function that determines whether a number isprime.

b) Use this function in a program that determines and prints allthe
prime numbers between 2 and 10,000. How many of these numbers doyou
really have to test before being sure that you have found allthe
primes?

c) Initially, you might think that n/2 is the upper limit forwhich
you must test to see whether a number is prime, but you need onlygo
as high as the square root of n. Why? Rewrite the program, and runit
both ways. Estimate the performance improvement.

I want sparate part a, part b and part c for C programcode..... I haven't finished part b and c. I need outputfile. What you think my source code? I need to your help... Here ismy source code

void main()

{

int n,m,k,i,max;

char c;

repeat: max=0;

k=2;

n=1;

printf("You want prime numbers upto:- ");

scanf("%d",&max);

printf("");

printf("%d ",2);

for (i=1;i<=max;i++)

{

again: m=(n/k)*k;

if (m!=n)

k=k+1;

else

goto try1;

if (k < n/2)

goto again;

else

printf("%d",n);

printf(" ");

try1: n=n+1;

k=2;

}

fflush(stdin);

printf ("Do you want to continue?(y/n):- ");

scanf("%c",&c);

if (c=='y')

goto repeat;

getch();

Explanation / Answer

please rate - thanks your program as a function #include<stdio.h>
#include <conio.h>
void prime(int);
int main()
{ int max;
char c;
repeat: max=0;
   printf("You want prime numbers upto:- ");
scanf("%d",&max);
prime(max);
fflush(stdin);
printf ("Do you want to continue?(y/n):- ");
scanf("%c",&c);
if (c=='y')
goto repeat;
getch();
}
void prime (int max)
{int n=1,k=2,i,m;
printf("");
printf("%d ",2);
for (i=1;i<=max;i++)
      { again: m=(n/k)*k;
       if (m!=n)
      k=k+1;
       else
      goto try1;
       if (k < n/2)
      goto again;
       else
      printf("%d",n);
      printf(" ");
try1: n=n+1;
      k=2;
       }
       }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote