help with functions

Write a function named Change() that has an integer parameter and also has another six integer reference arguments named Hundreds, fifties, twenties, tens, fives, and ones. the function is to consider the integers passed value as a dollar amount and convert the value into the lease number of equivalent bills.
The function should return the respective arguments in the calling function

input
enter an amount of money, to the nearest dollar: 1275

output:
12 Hundreds
1 fifties
1 twenties
0 tens
0 fives
5 ones

i did it the way shown at the bottom (the code below) is there a more efficient way to do this?



[#include <iostream>
#include<cmath>
int change(int,int,int,int,int,int,int);
using namespace std;
void main()
{
int hundreds,fifties,twenties,tens,fives,ones,dollars;
cout<<"Enter nan amount of money, to the nearest dollar";
cin>>dollars;
hundreds= 100;
fifties= 50;
twenties= 20;
tens= 10;
fives= 5;
ones = 1;

change(hundreds,fifties,twenties,tens,fives,ones, dollars);

}
int change(int h, int fi, int tw, int t, int f, int o ,int da)
{
int th, tfi, ttw,tt,tf,to;

th= da/h;
tfi= (da%h)/fi;
ttw= (da%fi)/tw;
tt= tw%t;


tf= t%f;

to= f/o ;
cout<<th<<"Hundreds"<<endl ;
cout<<tfi<<"fifties"<<endl;
cout<<ttw<<"Twenties"<<endl;
cout<<tt<<"Tens"<<endl;
cout<<tf<<"fives"<<endl;
cout<<to<<"ones"<<endl;
return 0;




}
]
Topic archived. No new replies allowed.