/*Write function that accepts 2 references arguments and swap those variable contents. Call this function form main anad display the swap result*/
#include<iostream>
using namespace std;
void swap(int& a, int&b){
int c;
c=a;
a=b;
b=c;
}
int main(){
int x=25,y=35;
swap(x,y);
cout<<"X="<<x<<" Y="<<y;
return 0;}
If we use this same code in C programming it would look like as
void swap(int *a, int *b){int c;
c=*a;
*a=*b;
*b=c;
}
0 Comments had been done yet:
Post a Comment