Download presentation
Presentation is loading. Please wait.
Published byἈναίτις Σπηλιωτόπουλος Modified over 6 years ago
1
The Run-Time Stack and Reference Parameters
2
float average (const float val1, const float val2) {
? 4 6 ? 5 ? num1 num2 the_average main() ? 4 6 ? 5 4 ? float average (const float val1, const float val2) { float ave = (val1+val2)/2; return ave; } int main() { float num1=4, num2=6, the_average=4; the_average = average (num1, num2); return 0; }
3
void swapVal (int val1, int val2) { int temp = val1; val1 = val2; val2 = temp; return; }
void swapRef (int & val1, int & val2) { int temp = val1; val1 = val2; val2 = temp; return; } int main() { int a = 7, b = 2; cout<<a<<" "<<b<<endl; swapVal(a, b); cout<<a<<" "<<b<<endl; swapRef(a, b); cout<<a<<" "<<b<<endl; ...
4
void get_point(float & x, float & y) { cout << “enter x value”;
b main() a ? 5 8 ? void get_point(float & x, float & y) { cout << “enter x value”; cin >> x; cout << “enter y value”; cin >> y; return; } int main() { float a, b; get_point (a, b);
5
End of Session
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.