I was doing one of the practice problems but when i run the program and choose the 99 bottles of beer, it begins to count down from 74 rather than the 99.
Are you sure the text of the lines from 99 to 75 are not 'gone' in the console? If too much text is written in the console, it'll display the last lines only. Try adding a cin.get() to see what appears every time one loop is completed!
I agree with @Basv the output can't fit on the console size , @TarikNeaj it should compile even if you din't return anything though that will remain an error when using such functions
Because there is nothing wrong with the code, see below.
@andy1992
It is undefined behaviour, not an error. What will happen is that when the function reaches the end, the function will return whatever value is in the return register ( Probably EAX ).
@OP
To test the output theory, output the bottles function to a file.
Undefined behavior is allowed to cause compile-time error.
the function will return whatever value is in the return register
Or 0. Or something else. It is also unknown if it will cause stack pointer to change. I am being pedantic here, but expecting some concrete results is worse than allowing such situation to happen.
To test the output theory, output the bottles function to a file.
To add to that: On Windows you can redirect output to file without modifying code by calling your program as program.exe > output.txt