How to display all of my prime numbers in this bool function

Well so far I managed to show an output but only from the 'main' functions. I have placed the function call for the bool function but it doesnt show when i run my program. it sure doesn't have any errors and it compiles just fine.


#include <iostream>
using namespace std;

bool isPrime(int val);

int main() {

cout << endl << endl;
cout << " Prime Numbers: " << endl;
cout << "----------------------" << endl;

isPrime();

return 0;
}

bool isPrime(int val) {
for(int val = 0; val >= 0; val++) {
if(val % 2 == 0) {
cout << val << " is a prime number. " << endl;
return true;
}
else {
return false;
}
}
}

I know there is something small that i don't see
it sure doesn't have any errors and it compiles just fine.


Impossible, there is 1 error I see immediately. Try compiling it and it should be very obvious.
I see that i need a value but I dont know exactly what to put as the arguement for the call functions
You were given good advice in the other thread you opened, don't ignore it:
http://www.cplusplus.com/forum/general/30924/#msg167561
http://www.cplusplus.com/forum/general/30924/#msg167565
R u trying to find prime no. or what ?
It needs to display all prime numbers down between 1 to 100
Topic archived. No new replies allowed.