This file contains 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 characters
int getNumChips(int val){ | |
int chips[6]={100,50,25,10,5,1}; | |
int numChips=0; | |
size_t n = sizeof(chips)/sizeof(chips[0]); | |
for(int i=0; i<n; i++){ | |
numChips += val/chips[i]; | |
val = val % chips[i]; //only works if val is an integer | |
} | |