classifying number

Question 2.

Write a function, initialVar, to initialize the variables such as zeroNum, oddNum and evenNum using the paramete reference technique.
Write another function getNum to get the integer number.
Write a third funciton determineNum to detemine whether the number is odd, even or zero. This function also increments the appropriate count.
Write a fourth function printResult to print the results
Lastly write the main function to call these
a. call the functionb initialVar

b. Prompt the user to enter 10 numbers.

c. For each of the number in the list

– call function getNum

– output the number

– call function determineNum

d. Call the function printResult
Please try writing the code yourself. When you get stuck for 30 minutes, post what you have and ask specific questions.
#include <iostream>

int initialVar();
int getNum();
void determineNum(int num, int &evenNum, int &oddNum, int &zeroNum);
void printResult(int evenNum, int oddNum, int zeroNum);

int initialVar ()
{ int evenNum = 0;
int oddNum = 0;
int zeroNum = 0;

}

int getNum()
{
int n;

std::cout << "\n\nInsert the interger number: ";

std::cin >> n;
return n;
}


void determineNum(int num, int &evenNum, int &oddNum, int &zeroNum)
{
if(num!=0)
{
if((num%2) ==0)
evenNum++;
else
oddNum++;
}
else
{
zeroNum++;
}
}

void printResult(int evenNum, int oddNum, int zeroNum)
{
std::cout << "Number of even: " << evenNum << std::endl;

std::cout << "Number of odd: " << oddNum << std::endl;

std::cout << "Number of zero: " << zeroNum << std::endl;
}

int main(int argc, char** argv)
{
int c;
c=initialVar ();
for (int repeat = 0; repeat < 10; repeat++)
{
determineNum(getNum(), evenNum, oddNum, zeroNum);
}

printResult(evenNum, oddNum, zeroNum);

return 0;
}
i cant trace back the syntax errors
I'd guess that
1
2
3
4
5
6
int initialVar ()
{ int evenNum = 0;
int oddNum = 0;
int zeroNum = 0;

}
is supposed to look like that
1
2
3
4
5
6
7
8
9
10
 int evenNum = 0;
int oddNum = 0;
int zeroNum = 0;

void initialVar ()
{ evenNum = 0;
oddNum = 0;
zeroNum = 0;

}
tqvm
Topic archived. No new replies allowed.