Skip to content

Instantly share code, notes, and snippets.

@CraigRodrigues
Created June 2, 2016 17:38
Show Gist options
  • Save CraigRodrigues/aeff70c00abf8fd4628f19e57c837a55 to your computer and use it in GitHub Desktop.
Save CraigRodrigues/aeff70c00abf8fd4628f19e57c837a55 to your computer and use it in GitHub Desktop.
My solution to CS50 pset1 - "Smart Water" (modified)
#include <stdio.h>
#include <cs50.h>
// function that returns the number of 16oz bottles used
int getBottles(int time, int showerflow)
{
return (time * showerflow)/16;
}
int main(void)
{
printf("How long did you shower today? (minutes)\n");
int time = GetInt();
printf("What is your showerhead flow? (oz/minute)\n");
int showerflow = GetInt();
int bottles = getBottles(time, showerflow);
printf("Minutes Showered: %i\n16oz Bottles Used: %i\n", time, bottles);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment