Skip to main content
Code indenting to improve readability.
Source Link
Luke Van In
  • 2.7k
  • 14
  • 26

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

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

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

Source Link

pset1 water task, function code ignored

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