C program to find that given number is prime or not.

#include<stdio.h>
#include<conio.h>
void main(){
int n,i;
clrscr();
printf("Enter a Positive Integer\n");
scanf("%d",&n);
if(n==1) 
printf("%d is Universal Prime Number\n",n);
else{
for(i=2; i<=n-1; i++){
if(n%i==0) break;
}
if(n==i) printf("%d is Prime Number\n",n);
else printf("%d is Not Prime Number\n",n);
}
getch();


}

No comments:

Post a Comment