Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<cs50.h>
- int penny(int n, int temp)
- {
- if(n>=25){
- n -= 25;
- temp++;
- }
- else if(n>=10 && n<25){
- n -= 10;
- temp++;
- }
- else if(n>=5 && n<10){
- n -= 5;
- temp++;
- }
- else if(n>=1 && n<10){
- n -= 1;
- temp++;
- }
- if(n>0)
- {
- //printf("n=%d/n",n);
- //printf("temp=%d/n",temp);
- return(penny(n, temp));
- }
- return temp;
- }
- int main(void)
- {
- float change;
- int n, count=0;
- do{
- printf("O hai! How much change is owed?\n");
- change = get_float();
- }while(change<0);
- n = (int)(change*100)%100;
- count = penny(n, count);
- printf("%d\n",count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement