Hello,
My program has to determine if a number that I enter is a prime number - which I believe I have done. But if the number is not a prime number, it should tell me the highest divisor of this particular number. At the moment, my program gives all the divisors if the number is not a prime. And the input range must be between 1 and MAXINT. Can anyone tell me how to get MAXINT? how to declare it?
Thanks
Code:
#include <stdio.h>
#include <process.h>
void main()
{
char your_name[12];
int number;
int i;
int remainder;
int not_divisible = 1;
printf("Hello!, please enter your name: ");
scanf("%s", your_name);
printf("Enter a number: ");
scanf("%d", &number);
printf("\nThe number you entered is: %d", number);
printf("\n");
for( i = 2; i < 10; i++ )
{
remainder = number % i;
if(remainder == 0 )
{
not_divisible = 0;
printf("\This number is divisible by %d", i);
printf(" and it is not a prime number");
}
}
if(not_divisible == 1) printf("This a prime number!");
printf("\n");
printf("Good-bye %s", your_name);
printf("\n");
system("pause");
}