That's clear,

because yo call the function 'sum' first in line 47 as the first argument of function 'sumResult'

and then in line 48 again. The variable 'n' is only valid in 'sum', after calling 'sum' again, the

last value is away. By the way you should insert a line to show the quotient of '(doublel)sum/(double)y'

and one who shows what is to put in by variable 'y'

May be it is also better to set first the quantity, how much values you want to read in.

If you want for example to calculate the average temperatures in Celsius or in Farenheit it would be

possible that you can get an Value of Zero degree. But in the example above you can't calculate

the average, you can't save a value of Zero.

Code:

#include <stdio.h>
// Shows a message with what the program is doing.
void ShowIntroduction(void)
{
printf("My program finds a sum etc\n");
}
// find the sum of the numbers enter until 0 value
int getsum(int *s)
{
int n;
*s = 0;
do
{
printf("Enter a integer: ");
scanf("%d", &n);
if (n > 0)
*s += n;
}
while(n != 0);
return *s;
}
// show the result
void sumResult(int a)
{
printf("The sum is %d\n", a);
}
// find the result of sum/y
double result(int s,int y)
{
double res;
res=double(s)/double(y);
return res;
}
int main()
{
int y, sum;
ShowIntroduction();
printf("Enter divisor: ");
scanf("%d",&y);
sumResult(getsum(&sum));
printf("quotient: %lf\n", result(sum,y));
return 0;
}