**Prime number:**
-A number that only divisible by the 1 or by itself is known as prime number.

prime numbers:

2,3,5,7,11,13,.......

Not prime numbers:

4,8,9,10,.....

program-

#include < stdio.h>

int main()

{

int n,i;

printf("Enter Numbern");

scanf("%d",&n);

for(i=2;i< n-1;i++)

{

if(n%i==0)

{

printf("It is not Prime");

n=0;

}

}

if(n!=0)

{

printf("It is a Prime Number");

}

}

output-

Enter Number

12

It is not Prime

Enter Number

13

It is a Prime Number

-We run the loop from i=2 to i=n-1, and divide n by every possible value of i

-If n was divisible by any of these value then it is not prime number otherwise it is prime number.

Read More →

R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!