#include <iostream>
using namespace std;
void change(int amount,int &hundreds, int &fifties, int &twenties, int &tens, int &fives, int &ones);
int main()
{
int amount, hundreds, fifties, twenties, tens, fives, ones;
cout<<"Enter the amount of money: ";
cin>>amount;
change(amount,hundreds, fifties, twenties, tens, fives, ones);
cout <<amount<<" is "<< hundreds<<" hundreds, "<<fifties<<" fifties, "<<twenties<<" twenties, "<<tens<<" tens, "<<
fives<<" fives, "<<ones<<" ones.";
return 0;
}
void change(int amount, int &hundreds, int &fifties, int &twenties, int &tens, int &fives, int &ones)
{
hundreds = amount/100;
amount %= 100;
fifties = amount/50;
amount %= 50;
twenties = amount/20;
amount %= 20;
tens = amount/10;
amount %= 10;
fives = amount/5;
amount %= 5;
ones = amount;
}
Comments
Leave a comment