illegel

#include "stdafx.h"
#include<iostream>
using namespace std;


bool even (int);

int _tmain(int argc, _TCHAR* argv[])
{
int number;
cout<<"Enter the numbers.";
while(true)
{

cin>>number;
even (number);


}

bool even (int number)
{
int x;
x=number%2;
if(x=0)
return true;
else
return false;
}


why this error???!!
local function difinitions are illegal
I see nothing "illegal" about your code. However, you should never use an infinite loop, see while (true), and you're not using the return value of the even function. Also, in your even function, this line if(x=0) should be if (x == 0)
It's illegal because the curly parentheses ('{' and '}') don't match up in _tmain correctly. You only have one }, you should have two as there are two opening parentheses.

It's giving this error because it thinks that you've defined the function 'even' inside _tmain, due to mismatching parentheses.

Function definitions shouldn't be written within each other in C++.
Last edited on
thank you veltas.as you said i didn't have } for int main
I have another question about this program but I will ask it in another topic
Topic archived. No new replies allowed.