PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS PRIME OR NOT
#include #include void main() { int i,j,k=0,n; clrscr(); printf("enter the value of n"); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { if(i%j==0) k++;} if(k==2) printf("%d is prime number\n",i); } getch(); }
No comments:
Post a Comment