OriginalGriff gives you the answer (and a +5 to him from me); let me give you some further advice. You have declared all of your int variables and have not initialized them. This is the source of many bugs. I am trying to differentiate the following 2 styles of code writing:
int x;
x = ...;
int x = ...;
In the first case, the code provides a mechanism for using an undefined variable. This also involves more code to do the same thing. This also provides a mechanism for the programmer to 'forget' about a variable, which is not a major problem, but it is just coding cholesterol which (1) clogs up your programming arteries and (2) makes the code harder to understand for someone reading it.
In the second case, the variable is defined and initialized in one statement. These two actions go together, and someone reading the code will find it easier to understand. To improve this a step further, (C++ only; doesn't work the same in C) the variable should not be defined and initialized until it is needed. For your code above, the totalage and averageage values should be moved from the lines at the top and instead be defined and initialized on the two lines where you do the calculations.
There are many studies showing that the number of bugs correlate with the number of lines of code in a program, and likewise that programs with distributed logic (using multiple lines to do one thing) are harder to understand and maintain. In short, "less code is better code".