I have to create a recursive function that tells you the number of ways a number of cents can be made into change. (Using quarters, dimes nickels, and pennies).
So f
#include <stdio.h>
int coins(int, int);
int main(void){
int num;
printf("Enter an amount of change in cents: ");
scanf("%d", &num);
printf("There are %d ways to make change for %d cents.\n", coins(num, 0), num);
return 0;
}
int coins(int amt, int kind){
static int kinds[4] = {25, 10, 5, 1};
int ways=0, i, n;
if(kinds[kind] == 1)//always divisible
return 1;
n = amt / kinds[kind];
for(i = 0; i <= n; ++i)
ways+=coins(amt-kinds[kind]*i, kind + 1);
return ways;
}