Skip to content

Commit 41fa1e6

Browse files
c++ programs
1 parent d1fe7b6 commit 41fa1e6

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

CallByAddress.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//call by address
2+
3+
#include<iostream>
4+
using namespace std;
5+
6+
int sum (int*,int*);
7+
int main(){
8+
int a=5,b=6;
9+
int s=sum(&a,&b);
10+
cout<<"sum is "<<s;
11+
return 0;
12+
}
13+
14+
int sum(int *p,int *q){
15+
return(*p+*q);
16+
}

CallByReference.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//call by Reference
2+
3+
#include<iostream>
4+
using namespace std;
5+
6+
int sum (int &,int &);
7+
int main(){
8+
int a=5,b=6;
9+
int s=sum(a,b);
10+
cout<<"sum is "<<s;
11+
return 0;
12+
}
13+
14+
int sum(int &x,int &y){
15+
return(x+y);
16+
}

CallByValue.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//call by value
2+
3+
#include<iostream>
4+
using namespace std;
5+
6+
int sum (int,int);
7+
int main(){
8+
int a=5,b=6;
9+
int s=sum(a,b);
10+
cout<<"sum is "<<s;
11+
return 0;
12+
}
13+
14+
int sum(int x,int y){
15+
return(x+y);
16+
}

0 commit comments

Comments
 (0)