This program receives an input number from user and check if the number is prime number or not.The number is divided by 2, 3 and 5 to see if the remainder of the division is 0. If the remainder is zero, then the number is not prime otherwise, it is prime number.
We compiled the program using Dev-C++ compiler version 220.127.116.11 installed on a Windows 7 64-bit system. You may use other compilers such as Turbo C++ 3.0 after modifying the program source code. This is necessary to avoid any error in the program.
We recommend you to learn following C programming concepts before you begin with the example program.
- C Reading Input Values
- C Arithmetic Operators
- C Variable and Constants
- C Flow Control Structures
- C For Loop
Prime numbers are very important topic in mathematics. It is usually easy to find the small prime numbers, but very difficult to identify a prime number, when the numbers grow larger.We want to write a program to test whether a given number is a prime number or not.What is a Prime number ?
Any positive number greater than 1 which is divisible only by itself and number one is called a Prime number, all other numbers are Composite numbers.
63 = 3 x 21
The number 63 has two factors 2 and 21, therefore it is a composite number.