#include<stdio.h> int main() { int i,n; int count=0; printf("enter a number :"); scanf("%d",&n); for(i=1;i<=n;i++) { if(n%i==0) { count++; } } if(count==2) { printf("%d it is a prime number\n",n); } else { printf("%d it is not a prime number\n",n); } }
Read More : What is Prime Number ?
OUTPUT :
If the number is Prime:
If the number is Not Prime:
No comments:
Post a Comment