Just tried to make a quick prime number checker:
#include <iostream>
#include <cmath>
using namespace std;
void askForNumber();
bool checkPrime();
void printPrime();
void printNotPrime();
int numberEntered;
int x = 2;
bool isPrime = true;
int main(){
askForNumber();
if(checkPrime(numberEntered) == true){
printPrime();
}
else{
printNotPrime();
}
return 0;
}
void askForNumber(){
cout << "Enter a number to see if it is prime: ";
cin >> numberEntered;
}
bool checkPrime(int enteredNumber){
while(x < sqrt(enteredNumber)){
if(enteredNumber % x == 0 && enteredNumber != x){
return false;
}
x++;
}
}
void printPrime(){
cout << numberEntered << " is prime!";
}
void printNotPrime(){
cout << numberEntered << " is not prime.";
}
I don't need help making it work, just the errors I get at line 6 and 16:
6: 'too many arguments to function `bool checkPrime()'
16: 'at this point in file'
Thanks.