Right now your code is just printing m
, bottles
is only defined, it is never called.
If you want to declare a variable, but not initialize it, int b;
is what you would write. int b = b;
assigns a new variable (b
) to the previous b
, of which you have none.
In "int bottles(int b)
", you're saying you want a function ('bottles') who will take an argument ('b'); what you probably don't see, however, is that b
is not the same variable we just declared, b
is another variable (more specifically, a parameter) that is declared inside the scope of our new function. b != b
. That said, your bottles function should take an amount of minutes m
as an input argument, not b
or bottles. Lastly, even if your function was properly defined, you're still not calling it, as in something like printf("%i", bottles(m));
.
All things considered there's multiple issues preventing your code from returning the correct value. Don't worry though, go back and watch Zamyla's walkthrough (again if you already have), write down the program in pseudo-code before you even attempt writing it in pure C, then write the entire program in int main
, only when it passes check50 should you try to make it more complex by adding another function.
Here's bottles
rewritten properly, though you will still have to integrate it properly in your code when you get there.
int bottles(int m);
{
int bottles = /*FORMULA FOR BOTTLES*/;
return bottles;
}