Value Call
Value Call : This program is shows us how to call a function.
There are two ways of calling a function. We have used call by value method to call the function.
Code:
#include<iostream>
using namespace std;
int add(int *a, int *b)
{
cout << “a = ” << *a << ” b = ” << *b <<endl;
int c = *a+*b;
*a=76;
*b=56;
cout << “a = ” << *a << ” b = ” << *b <<endl;
return (c);
}
int main()
{
int x=4,y=7;
cout << “x+y= “<< add(&x,&y) << endl;
cout << “x = ” << x << ” y = ” << y <<endl;
}
Output:
Note:
This Program is Written and compiled on “Dev c++”.
Explanation:
We used two header files iostream and conio, iostream is for using functions like cout & cin and conio for using function clrscr & getch .
clrscr is used to clear the screen & getch holds the console window.
cout & cin functions are used here for taking input and showing output.
I hope that you understood the program very well even though if you face any problem regarding the above code or you want to share your views with us. Then please do contact us ….
Related articles across the web
The post Call by Value appeared first on Programming.