0

Below is my code for the pset 1, im not sure why but whenever i put negatives for the "Minutes" i get a negative "Bottles" rather than an error. Help would be appreciated.

#include <cs50.h>
#include <stdio.h>

int main(void)
{
    //input
    printf("Minutes: ");

    if (input > 0)
    {
        //output = input*12
        printf("Bottles: %d\n", get_int()*12;
    }
    else
    {
        printf("Number must be an integer\n");
    }

}
1
  • You are missing a closing parentheses after the get_int()*12 Jan 1, 2018 at 4:40

1 Answer 1

0

Well, get_int won't prevent the user from entering a negative number, so you will simply print that number times 12.

I can't see what input is in your code.

The spec says that you can assume the user will only enter a positive integer, so you don't need to be checking for it anyway.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .