- Program :
#include <iostream>
using namespace std;
void swapNums(int &x, int &y)
{
int z = x;
x = y;
y = z;
}
int main(){
cout <<"\n----------------FUNCTION PARAMETERS----------------\n";
cout <<"\n----------------Pass By Reference----------------\n";
int a = 10, b = 5;
cout << "Before swap: " << "\n";
cout << a <<" and "<< b << "\n";
swapNums(a, b);
cout << "After swap: " << "\n";
cout << a <<" and "<< b << "\n";
return 0;
}
- Output :
No comments:
Post a Comment