1) Line 10 is illegal C++. When delcaring an array on the stack, you can only use a constant value for the size.
(And even if it were legal, you haven't actually specified a value for
x.)
2) What is
j for? You expect the user to input a value into it, but it never gets used anywhere.
3) Nowhere do you ever populate array with any values, so when you're reading values from it, you're reading nonsense.
4) The expression
z % 2 == 0
can only ever evaluate to
false
or
true
. When converted to integers, this means it can only ever evaluate to 0 or 1. So at line 22, you're only ever looking at the first two elements of the array.
The same is true for line 27.
5) At line 22, the semicolon at the end of the line terminates the entire if statement. This means that your code is the same as:
1 2 3 4 5
|
if(array[z % 2 == 0])
{
;
}
even_average = even_average / array[z];
|
The same is true for line 27.
You should remove the semicolons at the ends of those lines.
6) At lines 35 - 37, what is the point of changing the output format on cout after you've finished outputting any text? Shouldn't you have done that before you output anything?