I'm new to C++, trying to make a simple program that runs prime number from 3 to 300 but there seems to be this problem:
main.cpp:23:27: error: no match for ‘operator+’ (operand types are ‘std::string’ {aka ‘std::__cxx11::basic_string’} and ‘int’)
What are the mistakes in my code? I know there's plenty, but I appreciate any support to point them out for me, thanks.
int main() {
int i = 0;
int num = 0;
string prime = "";
for (i = 3; i <= 300; i++) {
int counter = 0;
for (num = i; num >= 1; num--) {
if (i % num == 0) {
counter = counter + 1;
}
}
if (counter == 2) {
prime = prime + i + " ";
}
}
cout << "Prime numbers: ";
cout << prime;
}