Solved Why my short C++ code says inval declaration

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

int main()

{
//variables
int number=0;

//start
cout<<"Enter a number\n"; cin>>number;
primeChecker(number);


system("pause");
return 0;
}

//calculations
//declaration

void primeChecker{int num){
//local variables
float sqNumber=0;int eval=0;
if (num>1&&num<1000){//Big if
sqNumber=sqrt(num);
eval=num%sqNumber;
if(eval==0){
cout<<"True\n";
}
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 •

#1
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 •

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

Report •

#3
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

#4
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