Created
June 19, 2019 10:26
-
-
Save Praful932/42ff3ec3dbac3804582707788dab7d39 to your computer and use it in GitHub Desktop.
Revisions
-
Praful932 created this gist
Jun 19, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ //greedy least no of coins for change #include<stdio.h> #include<cs50.h> #include<math.h> int main(void) { float n; int coin=0; do { n=get_float("Change owed: "); }while(n<0); n=round(n*100); while(n>=25) { n=round(n-25); coin++; } while(n>=10) { n=round(n-10); coin++; } while(n>=5) { n=round(n-5); coin++; } while(n>=1) { n=round(n-1); coin++; } printf("%d\n",coin); }