C++ Program For Call by Reference Function
Master C++ with Real-time Projects and Kickstart Your Career Start Now!!
Program 1
//Program by call by reference
#include<iostream>
#define clrscr() system("cls")
using namespace std;
//void xyz(int *a);
void swap(int *a,int *b);
int main()
{
int a,b;
clrscr();
cout<<"\nEnter two number: ";
cin>>a>>b;
cout<<"\n Before swaping: "<<a <<" "<<b;
swap(a,b);
cout<<"\n After swaping: "<<a <<" "<<b;
// //xyz(a); // call by value
// xyz(&a); // call by reference
// cout<<a;
return 0;
}
void swap(int *a,int *b)
{
*a=*a+*b;
*b=*a-*b;
*a=*a-*b;
}
// void xyz(int *a)
// {
// ++*a;
// }
Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

