#include <cs50.h>
#include <stdio.h>
int main(void)
{
int min;
do
{
printf("Minutes: ");
min = get_int();
}
while(min <= 0);
return 0;
printf("Bottles: %i\n", min * 12);
}
OK i am really new at c. The code should work like this: If the user types in a negative integer it will continue to ask for the integer otherwise it should run the printf statement at the end but that is not happening. Can someone help me please?
Move the return 0;
line after the printf
function, because the return 0;
let your application finish. --> So no printf("Bottles: %i\n", min * 12);
would have been called.
int main(void)
{
int min;
do
{
printf("Minutes: ");
min = get_int();
}
while(min <= 0);
printf("Bottles: %i\n", min * 12);
// Change the position of return
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With