CALL BY ADDRESS
PROGRAM
#include <iostream>
#include <conio.h>
void main()
{
int a = 10, b = 5;
swap(&a,&b);
cout << a << "&" << b;
}
void swap(int *m,int *n){
int temp;
temp = *m;
*m = *n;
*n = temp;
}
OUTPUT
OUTPUT
- 5&10
CALL BY REFERENCE
PROGRAM
#include <iostream>
#include <conio.h>
void main()
{
int a = 10, b = 5;
swap(a,b);
cout << a << "&" << b;
}
void swap(int &m,int &n){
int temp;
temp = m;
m = n;
n = temp;
}
- 5&10
No comments:
Post a Comment