Prime number in C.

Program to find prime number in C.

Prime number : A prime number is a number whose only factors are 1 and itself. That means there is no whole number that evenly divides the prime number.

Let’s write a program to find prime number in C.

Step 1: Let’s open turbo c and write the following code:

//Add preprocessor file


void main()

//declare variable
long int i,n,c=0;

//clear screen

printf(“enter any number : ”);

//Assign value in variable n
if (n%i==0)
printf(“this is prime number”);
printf(“this is not a prime number “);

Step 2: Now save it by pressing F2 and name it prime.cpp.

Step 3: After save it ,Compile it by pressing ALT+F9 to check errors and correct them.

prime compile

Step 4: Now run the program by click on Run or by pressing ALT+R and see the output .

Output :