c program to check prime number
//program to find prime number or not using c programming
#include<stdio.h>
#include<conio.h>
// program starts from here after main() function
void main(){
int n;
int i,count =0;
// count is incremented when the loop is true.
printf("Enter the number\n");
scanf("%d",&n);
for (i=1; i<=n; i++){
if(n%i==0){
count++;
}
}
// for the prime number the no of count is 2
// number is divided by 1 or itself(given number) so count ==2
if(count ==2){
printf("%d is prime number.\n",n);
}
// for the composite number the number is divided by more than 2 number.
else{
printf("%d is not prime number\n",n);
}
getch();
}