Question
Program: IsPrime Please help complete the program below in C language. A file contains an unknown number of positive integers. The name of the file
Program: IsPrime
Please help complete the program below in C language.
A file contains an unknown number of positive integers. The name of the file is known to your program via argv[1]. Write a C program that will read each number, determine whether or not the number is a prime number or not, and print out the number and its primeness. For example, if the file contained the integers:
11
18
99
2
27
23
1
5
10
Then your program would output:
11 is prime.
18 is not prime.
99 in not prime.
2 is prime.
27 is not prime.
23 is prime.
1 is not prime.
5 is prime.
10 is not prime.
Read your book. Use the table of contents. Use the index. Love your best friend. You should love your math book too.
You should recall that a prime number has exactly two divisors: 1 and itself. Thus, 2 is a prime number. It is the only even number that is prime. One is not a prime number.
You should have the main function call a function named IsPrime. This function returns 1 if the number provided is a prime number and 0 if the number is not a prime number.
int IsPrime( int n ) ;
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