Power By Dholu Production

Responsive Ads Here

Tuesday, April 24, 2018

WAP to illustrate the concept of call by reference|C++


#include<iostream> 
using namespace std;   
void swap(int *x, int *y) 

 int swap; 
 swap=*x; 
 *x=*y; 
 *y=swap; 

int main()  
{   
 int x=500, y=100;   
 swap(&x, &y);  // passing value to function 
 cout<<"Value of x is: "<<x<<endl; 
 cout<<"Value of y is: "<<y<<endl; 
 return 0; 
}