Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- /* Check whether a number given is prime or not.*/
- main()
- {
- int A, num;
- #define max 2147483647
- #define min -2147483648
- printf("Enter an integer between and including -2147483648 and 2147483647: ");
- scanf("%d", &num);
- if(num < min || num > max){
- printf("This is not a valid input. Aborting.\n");
- return 0;
- }
- for(A=2; A<num/2; A++){
- if(num % A == 0){
- printf("%d is not a prime number. It is completely divisible by %d.\n",num,A);
- return 0;
- }
- }
- printf("%d is a prime number.\n",num);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement