Saturday, 15 March 2014

c++ - How to return values from a void function? -



c++ - How to return values from a void function? -

here parts of programme , need homecoming value of length main help?

void getlength(double length) { cout << "enter length: "; cin >> length; if (length < inval){ cout << "do not take negative values length. seek again: "; cin >> length; } homecoming length; } .... int main() { double length = 0; double width = 0; double area = 0; getlength(length); getwidth(width); calcarea(length, width, area); printdata(length, width, area); }

make parameter length reference. void getlength (double & length) , delete return. after calling function passed parameter has value assigned in function.

c++

No comments:

Post a Comment