How to check a number's prime or not by C

[color=Blue][size=2]dear friends, I need help in C programming, how to check a number is prime or not. the following instructions:

Checking Prime Numbers


Prime number is an integer more than 1 that can not be divided into more integers by integers other than by himself. Examples of prime numbers: 2, 3, 5, 7, 11, 13, 17, etc.. For example, 9 is not prime because 9 can be divided by 3. Is -5 primes? According to the above definition, a prime number is a positive integer, so -5 is not prime.

Write out a program that reads N numbers (-32 000 <N <32,000). For each number, determine whether the number is prime or not.


Use the function eof (names and how to use different functions for Pascal and C) to check whether the input has reached the end of file.

Input Formats:
Many lines, from 1 to 100 lines, each containing an integer N.

Output Format:
For each row, print YES if N is prime, or NO if not.

Sample Input


Sample output




NO (CR)[/size][/color]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!