I am trying to create a prime factorization c++ program, and halted immediately by this "else" error. I would really appreciate some assistance with my coding. I am new to c++, so I am just getting used to the rules. Here is what I have so far:
#include <iostream>
using namespace std;
int main() {
int number=0; // the input number
int i=2;
int j=0;
// get the user input
cout<<"Please Enter a Number :";
cin >>number;
// reprompt loop if incorrect (input < 2)
while (number < 2) {
cout<<"Enter a Number Greater than 2:";
cin>>number;
}
// input is composite
if (number % i == 0) {
cout<< number <<"is a COMPOSITE number" << endl;
for (i=2; i<=number; i++) {
if (number % i == 0) {
cout << i << " Has Been Found as A Prime Number of " << number << endl;
}
}
else {
cout<< number <<"is a PRIME number" << endl;
}
}
return 0;
}