coin_value, quarters,num and amount_left are variables that contains random values at the first place because they are not initialized ,to check this write :
1 2 3 4
|
cout << coin_value << endl;
.
.
cout << amount_left << endl;
|
after the declaration of these variables
In the computer_coins function ,when your coin_values is between 0 and 99 those variables got assigned ,the random values are gone ..everything is ok
when you enter a coin_value,whice is out of rang(0,99) you got the error only because the parameters are referenced, every change occurs to these parameters affects directly to coin_value, quarters,num and amount_left
try to imagine this scenario
int coin_value;// may contains randomly 2365487
int change; // may contains randomly 548154
int quarters; // may contains randomly 658954
int num; // may contains randomly 8547452
int amount_left; // may contains randomly 2395874
You input the coin_value(for exp 455) ,now only of coin_value is changed to to 455
the program call the function computer_coins and send the parameters
computer_coins(455,2365487,548154,658954)
In the function ,the if condition is not correcte, goes to else ..,function ended
these are still the same
finaly you got an input
455cents will be:
2365487quarters
548154dimes
658954pennies |
Please next time dont edit,Your problem my help others