I'm trying to calculate the volume, cost, charge, and profit by defining a function and having a function call in the main. I have defined my functions but I guess I don't know how to put the function call in the main, my answers are coming out weird. Can anyone help my with this?
Code:#include <iostream>using namespace std; double cal_vol (double l, double w, double h) //volume function { double V; V = l * w * h; return V; } double cal_cost (double V)//cost function { double C; C = V * 0.23; return C; } double cal_charge (double V)// charge function { double D; D = V * 0.5; return D; } double cal_profit (double D, double C)//profit function { double P; P = D - C; return P; } main() { int l, w, h; double cal_vol, cal_cost, cal_charge, cal_profit; cout << "Enter crate length : "; cin >> l; cout << "Enter crate width : "; cin >> w; cout << "Enter crate height : "; cin >> h; cout << "The crate's volume is " << cal_vol << endl; cout << "The crate's cost is " << cal_cost << endl; cout << "The customer's charge is " << cal_charge << endl; cout << "The profit is " << cal_profit << endl; system("pause"); }



LinkBack URL
About LinkBacks


