I'm a beginner with programming in C and I have a problem to solve at which point I get stuck.
So my program reads numbers until the value 0 then it calculates the sum of numbers. Then I have to write a function which displays the sum. Also, my program read a number "y" from keyboard and I need to find the result of the sum/y.For example if the result of the sum is 10 and I enter y=3 the function result should return the result of 10/3.
My program need to be built with functions. I received the functions name with parameters and I built them like this:
// Shows a message with what the program is doing.
printf("My program finds a sum etc");
// find the sum of the numbers enter until 0 value
if (n > 0)
while(n != 0);
// 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)
The problem is that my program finds the sum but when it should display the result of the sum / y it asks me to give the values again for the sum until 0 value then the program closes.I think I apelate the result function in a wrong way.How to correct this?