Check Given Number is Prime or Not
C program to Check Whether a Number is Prime or Not.
Example : pgm.c
#include<stdio.h> int main(){ int i=2,n,s=0; printf("\nEnter the Number : "); scanf("%d",&n); while(i<=(n/2)){ if(n%i==0) { s=1; break; } i++; } if(s==0) printf("\n%d is Prime Number",n); else printf("\n%d is Not a Prime",n); return 0; }
Output:
Enter the Number : 11
11 is Prime Number
11 is Prime Number