I didn't mean to sound insulting, i was just showing you what you
did wrong, and i wouldn't be answering questions on the boards
if i wasn't interested in being helpful.
You should try implementing one function to do the job, obviously
if you are just starting out, classes are a little bit down the road.
When you do come to classes though, remember what i said,
as that would be a good basic class to get you comfortable
with them.
Also, one last thing, if you want to be able to return both values
from a function, there are two ways you could do it in this
program:
1) use a macro to define the maximum number of voters in the
district, and let the function return the results for one particular
candidate - then subtract the two to find the result for the other
2) or the more typical way of using pass by reference - c++ has
features which simplify this significantly as opposed to using
pointers - i assume though that you have not encountered either
pointers or references yet, so i put this little program together
to show how to get multiple values returned from a function:
Code:
#include <iostream>
using namespace std;
void square2numbers (int &num1, int &num2);
//notice the void return type - not a
//requirement, just for demonstration
//also notice the ampersands (&) this part is important!
int main (void)
{
int a, b;
cout << "Enter number a: ";
cin >> a;
cout << endl << "Enter number b: ";
cin >> b;
square2numbers (a, b); //pass parameters as normal
cout << "The value of a-squared is: " << a << endl; //However, the parameters
cout << "The value of b-squared is: " << b << endl; //have been modified
return 0;
}
void square2numbers (int &num1, int &num2)
{
num1 *= num1; //squaring first parameter
num2 *= num2; //squaring second parameter
}
that should help you avoid a roadblock down the line