#include <stdio.h>
main() {
int n, c = 2;
printf("Enter a number to check if it is prime\n");
scanf("%d", &n);
for (c = 2; c
if (n % c == 0) {
printf("%d is not prime.\n", n);
break;
}
}
if (c == n)
printf("%d is prime.\n", n);
return 0;
}
/*-via Programming Hub for Android, a top rated Programming App on Google Play
https://play.google.com/store/apps/details?id=com.freeit.java*/
Sunday, August 16, 2015
Program: Check if Number is Prime
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment