Skip to content

Instantly share code, notes, and snippets.

@hareom284
Created August 4, 2020 16:47
Show Gist options
  • Save hareom284/4044a4a571048029c9c1ff8780f481c4 to your computer and use it in GitHub Desktop.
Save hareom284/4044a4a571048029c9c1ff8780f481c4 to your computer and use it in GitHub Desktop.
Harvard summer 2020 week 1
#include<stdio.h>
#include<cs50.h>
#include<math.h>
int main(void)
{ float dollars=0;
do
{
dollars = get_float("Chang owned:");
}while(dollars<0);
int cents = round(dollars*100);
int count=0;
while(cents!=0)
{
if(cents>24)
{
cents=cents-25;
count++;
}
else if(cents>9)
{
cents=cents-10;
count++;
}
else if(cents>4)
{
cents=cents-5;
count++;
}
else
{
count+=cents;
cents=0;
}
}
printf("%d",count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment