So I'm new to coding, and trying to make a program in C, where I enter a float value and it returns the minimum number of coins needed to represent that value. But I keep getting this error message:
c:16:19: error: cannot take the address of an rvalue of type 'float
printf ("%f", &change(f));
#include <stdio.h>
#include <cs50.h>
float change(float n);
int main(void) {
float f;
do {
f = get_float();
} while (f < 0);
change(f);
printf("%f", &change(f));
}
float change(float n) {
float pennies = 0.01;
float nickles = 0.05;
float dimes = 0.1;
float quarters = 0.25;
float coins = 0;
do {
n = n - quarters;
coins++;
} while (n >= quarters);
do {
n = n - dimes;
coins++;
} while (n >= dimes);
do {
n = n - nickles;
coins++;
} while (n >= nickles);
do {
n = n - pennies;
coins++;
} while (n != 0);
return coins;
}