Saturday, June 29, 2013

Write a program to find the given no is prime or not ?

Program:
#include<stdio.h>
#include<conio.h>

void main()
{
int n,i,x=0;
clrscr();
printf("\nEnter the no");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
x++;
}
if(x>1)
printf("\n the %d is prime",n);
else

printf("\n the %d is not prime",n);
getch();
}

Output
image
What is prime no?
the number which is not divisible by any other no except that no  is called prime no

Like the Post? Do share with your Friends.

No comments:

Post a Comment