I'm stuck in water week 1 problem. My program works according to the check50 but I have it gives me 3 errors which I have no clue what they mean:
:( rejects "foo" minutes /expected prompt for input, not exit code of 0 :( rejects "" minutes /expected output, not a prompt for input :( rejects "123abc" minutes /expected prompt for input, not exit code of 0
Now I'm not too familiar with these errors, but it seems that the check50 tried in an input "foo", then "" and then "123abc" which resulted probably in my program giving them a 0 value. Now, I though in the instruction, there was no need for loops. Can someone help me out with this? I'm fairly new to programmation.
Here is my code:
#include <stdio.h>
int main(void)
{
int bottle, minutes, num_bottles;
printf("Minutes: \n");
scanf("%d", &minutes);
bottle = 12;
num_bottles = bottle * minutes;
printf("bottles: %d\n", num_bottles);
}
Answer to my own problem:
#include <stdio.h>
#include <cs50.h>
int main(void)
{
int bottle = 12;
int num_bottles;
printf("minutes: \n");
int minutes = GetInt();
if (minutes > 0)
{
num_bottles = bottle * minutes;
printf("bottles: %d\n", num_bottles);
}
else
{
num_bottles = bottle * minutes;
printf("retry: ")
}
return 0;
}