how to display prime numbers in c code example
Example 1: prime numbers in c
#include<stdio.h>
main() {
int n, i, count=0;
printf("Enter Number");
scanf("%d",&n);
for ( i = 1; i<= n; i++) {
if (n % i == 1) {
count++;
}
}
if( count == 2) {
printf("Prime Number");
}
else {
printf("Not A Prime Number");
}
}
Example 2: prime number c program
int isPrime(int n) {
for (int i = 2; i < n; i++) if (n % i == 0) return 0;
return 1;
}