Monday, May 24, 2010

Sample c++ program using a function?

can u mail me a program that is using a fuction??????? prompt the user inside the function.... i like the prog... computing the GrossPay w/ the formula GrossPay=no. of days worked*daily rate......... tnx..

Sample c++ program using a function?
No, I can't. Do your homework yourself please, that's how you learn. And please try to speak English next time, thanks.





If you have a specific problem and/or question about the program as you write it, please feel free to ask.
Reply:Here's a quickie I threw together in a few minutes:





#include %26lt;iostream%26gt;


using namespace std;





double calculate (double hours, double rate);








int main() {


double hours,rate,gross;


cout%26lt;%26lt;"Enter hours worked:"%26lt;%26lt;endl;


cin%26gt;%26gt;hours;


cout%26lt;%26lt;"Enter rate:"%26lt;%26lt;endl;


cin%26gt;%26gt;rate;


gross = calculate(hours,rate);


cout%26lt;%26lt;"Gross pay: "%26lt;%26lt; gross;


return 0;





}





double calculate (double hours, double rate){


double grosspay;


grosspay = rate * hours;


return grosspay;


}


No comments:

Post a Comment