Hi everyone! I've been working on this program and I believe my functions on top are working, but in my int main I have a feeling it is wrong. I need to call getInput with no parameters and return the input, call/write isPrime to determine if the number is prime and return true if it is and false if it is not. This means dividing starting at 2 and going up to x/2. It then has to print out the list of prime numbers. If they want 2 print 1: 2 2: 3
So far I have
#include <iostream>
using namespace std;
int getInput(){
int N;
cout << "How many prime numbers do you want?";
cin >> N;
return N;
}
Also, isPrime takes an argument (an int), but you call it with no arguments.
if(isPrime(/**/) = true) There are a couple of issues with this: = is for assignment, so you assign true to isPrime (which makes no sense, right?). == is for comparison, so if (isPrime(13) == true) is what you want. Furthermore, since isPrime returns a bool, you don't need to compare it to a boolean literal (true or false), you can simply do: if (isPrime(13))
Other than that, I strongly recommend that you use [code][/code] tags and indent your code.