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

#### Howdy, Stranger!

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

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

Posts: 2Member
[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

Ddescription

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.

clues

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

23
-7
9000
1

Sample output

YES (CR)

NO (CR)

NO (CR)

NO (CR)[/size][/color]