Call by value
CODE:
CODE:
#include <iostream.h>
#include <conio.h>
void swap(int, int);
main()
{
clrscr();
int a, b;
cout << "Enter two numbers: ";
cin >> a >> b;
cout << "\nBefore Swapping:\n";
cout << "\na = " << a << " b = " << b;
cout << "\n\nAfter Swapping(call by value): \n";
swap(a, b);
getch();
}
void swap(int x, int y)
{
int t;
t = x;
x = y;
y = t;
cout << "a = " << x << " b = " << y;
}
For Further Reading,
0 comments:
Post a Comment