#include <iostream.h> void display_values(int a, int b) { a=1001; b=1001; cout << "The values within display_values are " << a << " and " << b<< endl; } void main(void) { int big = 2002, small=0; cout << "Values before function" << big << "and" << small << endl; display_values(big, small); cout << "Values after function" << big << "and" << small << endl; }<Run of Program> /* Values before function 2002 and 0. The values within the display_values are 1001 and 1001. Values after function 2002 and 0.
#include<iostream.h> void change_values(int *a, int *b) { *a=1001; *b=1001; cout << "The values within the display_values are " << *a << "and" << *b << endl; } void main(void) { int big = 2002, small=0; cout << " Values before function" << big << "and" << small << endl; change_values(&big, &small); cout << "Values after function" << big << "and" << small << endl; }<Run of Program> /* Values before function 2002 and 0. The values within the display values are 1001 and 1001. Values after function 1001 and 1001.
#include <iostream.h> void swap_values(float *a, float *b) { float temp; temp=*a; *a=*b; *b=temp; } void main(void) { float big=10000.0; float smal=0.00001; swap_values(&big, &small); cout << "Big contains" << big << endl; cout << "Small contains" << small << endl; }
#include<iostream.h> void swap_values(float& a, float& b) { float temp; temp=a; a=b; b=temp; } void main(void) { float big=10000.0; float small=0.00001; float& big_alias=big; float& small_alias=small; swap_values(big_alias, small_alias); cout << "Big contains " << big << endl; cout << "Small contains" << small << endl; }