Program:- #include <stdio.h> void main() { int n, i, a = 1; printf("Enter a number: \n"); scanf("%d", &n); for (i = 2; i <= n / 2; i++) { if (n % i == 0) { a = 0; break; } } if (a == 1) { printf("%d is a prime number", n); } else { printf("%d is not a prime number", n); }
No comments:
Post a Comment