Question

Can somebody check my evenSum in line 29 i dont know whats wrong

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;

void askValues(int num[], int max);
int evenSum(int num[], int max);


int main(){

int max=5, even=0, odd=0;
int num[max];

askValues(num,max);

	even=evenSum(num,max);
//	odd = oddSum(num,max);
	cout << endl << "Sum of all even values: " << even;
//	cout << endl << "Sum of all odd values: " << odd;

return 0;
}

void askValues(int num[], int max){
	cout << "Type 5 numbers: ";
		for(int i = 0; i <= max; i++)
		cin >> num[max];
}

int evenSum(int num[], int max){
	int even=0;
	int i;
	if(num[i] % 2 == 0);
		for(int i = 0; i < even; i++)
	return even;
}
Last edited on
The if statement should be inside the for loop, not the other way around.

The if statement should actually do something - as it stands currently, that semicolon after it means it does nothing.
Topic archived. No new replies allowed.