Asked by
AL MaMun (4 Golds)
Friday, 31 Jul 2020, 04:39 PM
at (Education
Tutorials)
|
|
|
|
A C program to check prime number : #include<stdio.h> int isPrime(int n) { int i; if(n<=1) return 0; for(i=2; i*i<n; i++) { if(n%i==0) return 0; } return 1; } int main() { int n, result; printf("Enter a Number\n"); scanf("%d", &n); result = isPrime(n); if(result==1) printf("%d is a Prime number", n); else printf("%d is not a Prime number", n); return 0; } |