Need help with a program that displays the prime numbers in


****C PROGRAMMING****

Need help with a program that displays the prime numbers in its command-line arguments, which are assumed to be integers. Example run of the program: 

./a.out 5 2 92 424 53 42 67 

output: prime numbers: 5 2 53 67 

1) Use atoi function in to convert a string to integer form.

2) Use the is_prime function provided in prime.c. 

int is_prime(int n)

{

int divisor;

if (n <= 1)

return 1;

for (divisor = 2; divisor * divisor <= n; divisor++)

if (n % divisor == 0)

return 0;

return 1;

}

Solution Preview :

Prepared by a verified Expert
Business Management: Need help with a program that displays the prime numbers in
Reference No:- TGS02932944

Now Priced at $10 (50% Discount)

Recommended (92%)

Rated (4.4/5)