Here is the actual question:
an interview The program has three seperate files within its own directory ie. primes,h, main.c and is_prime.c The table looks like this:
PRIMES WILL BE PRINTED.
How many do you want to see? 300o
1: 2
2: 3
3: 5
4: 7
5: 11
....
25: 97
26: 101
....
300: 27449
The question states: TExpalin how is_prime() works. Complete the program by writing main() in main.c. There 168 primes that are less than 1000. Does your program confirm this? How many primesnew are less than 10,000?
I hope this is better, sorry for the confusion.
In file primes.h:
#include<stdio.h>
#include<stdlib.h>
int is_prime(int n);
In file is_prime.c
#include "primes.h"
int is_prime(int n)
{
int k, limit;
if (n==2)
return 1;
if (n % 2 == 0)
return 0;
limit = n / 2;
for (k = 3; k <= limit; k +=2)
if (n % k == 0)
return 0;
return 1;
}
in