error: expected unqualified-id

I can't figure out this error. Can someone help, please?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
bool isPrime(int number);
{

primeNumber = isPrime(number);

if(primeNumber = true)
cout << "Prime Number" << endl;

bool isPrime(int number)
{
if (number == 0) return false;
if (number == 1) return false;
if (number == 2) return true;
if (number % 2 == 0) return false;

for (int i = 3; i < number; i = 2)

if (number % i == 0) return false;
}
}
Can you explain what the error is, what line? is it not compiling, runtime error at some line, error in output?
You have no main() to encompass your code, and your function implementation is within where main should be.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
bool isPrime(int number); // declaration in global, outside of main

int main ()
{
primeNumber = isPrime(number);

if(primeNumber = true)
cout << "Prime Number" << endl;

return 0;
}

bool isPrime(int number) //function implementation is also outside of main (only the call is in //main)
{
.....
}


also, do you have primeNumber declared as int already? Do you have anything assigned to number?
Last edited on
Topic archived. No new replies allowed.