First, when you call a function, you don't include its return type and/or its parameter(s) datatype(s). For example, the prototype for
double round(double x);
This means that
round() receives a
double and returns a
double. When we call it though, we call it like that
x is a
double variable. Watch the short on functions for more information!
Second, you should multiply the amount you receive from the user by
100 first, then round it using
round() because these functions, as their names suggest, round floating-point values to the nearest integer. And if you round the input first, then multiply it by
100 it'll always give you a multiple of
100. For example, if I entered
1.99, do you think your program should
1.99 first which gives
- then multiply
100 which gives
100 first which gives
- then round
199.0 which gives
Lastly, you're dividing by quarters, dimes, nickles and pennies anyway regardless of
q being >, < or = the divisor which is surely wrong since this is integer division and if
q is < the divisor, the result will be
0. Probably some conditions will be sufficient to solve this.
Also, no need to use 4 variables for each type of coins. You could have used just one variable adding the number of coins of each type to it like
int total = 0;
total += amount / quarters;
amount %= quarters;
total += amount / dimes;
amount %= dimes;
and so on.
EDIT: you should only output the total number of coins followed by a newline character.