Please click on 1-2 Ads to keep this website's Study Material FREE and regularly Updated.

Program 2: Write a C++ program using the concept of call by value as well as call by reference.

#include<iostream.h>
#include<stdio.h>
#include<conio.h>

void func(int x,int &y)
{
	x=x+10;
	y=y*3;
	cout<<"values of a and b in func :\n";
	cout<<x<<" "<<y;
}

void main()
{
	clrscr();
	int a=10,b=20;
	cout<<"initial values of a and b :\n";
	cout<<a<<" "<<b<<endl;

	func(a,b);

	cout<<"\nvalues of a and b after calling the func :\n";
	cout<<a<<" "<<b;
	getch();
}



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.