I am trying to set an error message for when the user gets wrong.
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int minutes, ounces, bottles;
do
{
printf("How many minutes do you spend in the shower?\n");
minutes = get_int();
if(minutes < 1)
{
printf("Error: Enter positive numbers only!\n");
}
}
while(minutes < 1);
ounces = (minutes * 192);
bottles = (ounces / 16);
printf("Minutes: %i\n", minutes);
printf("Bottles: %i\n", bottles);
}
All the tests are passing.
I am doing this inside the do
block as you may see above:
if(minutes < 0)
{
printf("Error: Enter positive numbers only!\n");
}
I want to know if this is the proper way to do it or if there is another way to know the do
block is repeating it?