I have a short code that I'm trying to debug, but am a little stuck write now. Basically all the code does is have the user input a number, and it will tell whether or not the number is prime. I keep getting a
#include <iostream>
#define PROMPT "Please enter a whole number: "
#define NOT_PRIME "The number is not a prime number. "
#define PRIME "The number is a prime number. "
#define DONE 0 /* ends successful program */
#define FIRST_FACTOR 2 /* initial value in for loop */
usingnamespace std;
int main(){
int i; /* loop counter */
char number; /* number provided by user */
cout << PROMPT; /* promt user */
cin >> number; /* wait for user input */
/* Prime numbers are defined as any number
* greater than one that is only divisible
* by one and itself. Dividing the number
* by two shortens the time it takes to
* complete. */
for(i == 2; i < number/2; ++i){
if( number%i == 0 )
{ //if divisible
cout << NOT_PRIME << number << "\n"; //not prime
return DONE; //exit program
}
}
/* if number is not divisible by anything
* than it must be prime */
cout << PRIME << number << "\n";
return 0; /* exit program */
}