0

I'm trying to grasp the use of functions with the cs50 library to complete the pset1 water task. My code will outright ignore the function I've written, I think this is due to line 10, but what am I missing?

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

//a function that takes 'a', multiplies that by 16 and divides 192 from this
int convert(int a);

int main(void)
{
    printf("How many minutes do you spend in the shower: ");
    int a = GetInt();

    if(a <= 0)
    {
        printf("You don't shower? Nasty./n");
        return 0;
    }
    else
    {
        printf("You use %i bottles of water per shower!\n", a);
    }
}

/* Function Argument */
int convert(int a)
{
    return 192/(16*a);
}

Many Thanks

2

There's nothing wrong with the function. You just never call it from main.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

0

You have an error in your printf function when you ask for a new line, you used "/" instead of "\"

printf("You don't shower? Nasty./n");

You must log in to answer this question.

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