Back To C Loops Index
//program to check whether a number is prime or not using while statement #include
#include
void main() { int i=2; int a; int prime=1; clrscr(); printf("enter number to check for "); scanf("%d",&a); while(i<=a/2) { if(a%i==0) { prime=0; break; } i++; } if(prime==1) { printf("number is prime "); } else { printf("number is not prime"); } getch(); }