Solved Why my short C++ code says inval declaration

October 21, 2011 at 19:28:21
Specs: Windows XP
#include <iostream>
using namespace std;
void primeChecker(int num);

int main()

int number=0;

cout<<"Enter a number\n"; cin>>number;

return 0;


void primeChecker{int num){
//local variables
float sqNumber=0;int eval=0;
if (num>1&&num<1000){//Big if
else {cout<<"False\n";}
}//End Big if
else {cout<<"The number is either too big or too small\n"; }
}//The primeChecker definition

See More: Why my short C++ code says inval declaration

Report •

October 21, 2011 at 19:29:44
ok i commented it as declaration but i meant to write definition..the declaration is actually right under namespace

Report •

October 21, 2011 at 19:44:34
now all i getting is invalid operands of types `int' and `float' to binary `operator%'

Report •

October 21, 2011 at 23:57:46
✔ Best Answer
In your definition of primeChecker you have

primeChecker{int num)

rather than

primeChecker(int num)

Report •

Related Solutions

October 22, 2011 at 04:33:32
damn even after i fixed a few things i cannot detect a prime number...I am trying to create a program that will say true if the number is prime and false if it is not...but i suck

Report •

Ask Question