-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions2.cpp
More file actions
34 lines (34 loc) · 761 Bytes
/
functions2.cpp
File metadata and controls
34 lines (34 loc) · 761 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
29
30
31
32
33
34
#include <iostream>
using namespace std;
/*
void main()
{
void swap(int,int); //prototype call by value
int a = 10, b=12;
cout<<"before swap a = "<<a<<"b = "<<b<<swap(a,b)<<endl;
cout<<"after swap a = "<<a<<"b = "<<b<<swap(a,b)<<endl;
}
void swap(int a, int b)
{
int t = a;
a = b
b = t
cout<<"in swap"<<endl;
cout<<"after swap a = "<<a<<"b = "<<b<<swap(a,b)<<endl;
}
*/
void main()
{
void swap(int &, int &); //prototype call by reference (address)
int a = 10, b=12;
cout<<"before swap a = "<<a<<"b = "<<b<<swap(a,b)<<endl;
cout<<"after swap a = "<<a<<"b = "<<b<<swap(a,b)<<endl;
}
void swap(int &a, int& b)
{
int t = a;
a = b
b = t
cout<<"in swap"<<endl;
cout<<"after swap a = "<<a<<"b = "<<b<<swap(a,b)<<endl;
}