expected expression before 'double' (sum problem with functions)
I'm a beginner with programming in C and I have a problem to solve at which I get stucked.
So my program reads positive numbers until the value 0 then it calculates the sum of numbers. Then I have to write a function which displays the sum. Also, after that I need to enterr a number "y" from keyboard and I need to find the result of the sum/y.
My program needs to be built with functions. I received the functions name with parameters and I built them like this:
Code:
#include <stdio.h>
// Shows a message with what the program is doing.
void ShowIntroduction(void)
{
printf("My program finds a sum etc");
}
// find the sum of the numbers enter until 0 value
int sum(void)
{
int s=0,n;
do
{
scanf("%d",&n);
if (n > 0)
s=s+n;
}
while(n != 0);
return s;
}
// show the result
void sumResult(int a)
{
printf("The sum is %d", 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;
scanf("%d",&y);
ShowIntroduction();
sumResult(sum());
result(sum(),y);
return 0;
}
The problem is that I get the error: "expected expression before 'double' "
Where is my mistake?