Hello everyone,
I finally figured out how to write the code I originally thought I was posting
on the weekend.
The purpose of this small program is to identify prime numbers.
It seems to work okay until a number is entered that is divisible by 11
(or an elevenish type number). Example-- 33 is identified as prime,
777 is identified as prime, etc.
Any help or comments on this code will be appreciated.
Here's the code. Thanks everyone.
Code:#include <stdio.h> int main(void) { int number; printf("Enter a number:\n"); scanf("%d", &number); int a; for(a = 2; a < number; a++) { if((number % a) == 0) { printf("%d is not prime.\n", number); break; } if((number % a) != 0) { printf("%d is prime.\n", number); break; } } return 0; }



LinkBack URL
About LinkBacks


