All major conceptual S2 C-Programs with Algorithms
#include <stdio.h>
void main(){
int n,flag=0,i;
printf("Enter the Number:");
scanf("%d", &n);
if (n<=1){
printf("Not a Prime Number");
}
else if(n == 2){
printf("A Prime Number");
}
else{
for(i=2 ; i<=(n/2) ; i++){
if(n%i==0){
flag = 1;
break; // this is important
}
}
if(flag == 0){
printf("A Prime Number");
} else {
printf("Not a Prime Number");
}
}
}