Is there a difference between Declaring a variable these 2 ways

I was wondering if this is basically the same thing? Or is one declaring x and the othe intializing x? what is the difference between declaring and intializing a variable?



1
2
3
4
5
int IsEven()
{
cout << "enter a number:";
int x;
}



or
[

1
2
3
4
int IsEven(x)
{
cout <<"enter a number:;
} 



thanks

The difference is that in the second function, x is a parameter whose value is supplied when you call the function.
For example:
1
2
3
4
5
int IsEven(x)
{
    return !(x%2)
}
// Now you can call IsEven(15), when x becomes 15 and the function returns 0 
Last edited on
Topic archived. No new replies allowed.