-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path21.cpp
More file actions
28 lines (26 loc) · 751 Bytes
/
21.cpp
File metadata and controls
28 lines (26 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//Value Swap Using Call By Value.
#include<iostream>
using namespace std;
void swap(int,int);
int main()
{
int a=10;
int b=20;
cout<<"Before Swap Function Calling: ";
cout<<"\na:: "<<a; // it will print 10
cout<<"\nb:: "<<b; // it will print 20
swap(a,b); // function calling
cout<<"\nAfter Swap Function Calling: ";
cout<<"\na:: "<<a; // it will print 10
cout<<"\nb:: "<<b; // it will print 20
return 0;
}
void swap(int x,int y) // x=a=10 & y=b=20 values copy
{
int temp;
temp=x; // temp=10
x=y; // x=20
y=temp; // y=10
cout<<"\nx:: "<<x; // it will print 20
cout<<"\ny:: "<<y; // it will print 10
} // function end