void main(){
int a=10;b=20;
cout<<"Before Exchanging";
cout<<a << b;
exchange(&a,&b);
cout<<"After Exchanging";
cout<<a << b;
}
void exchange(int *a,int *b){
int *c;
*c=*a;
*a=*b;
*b=*c;
}
Output of the above Program:
Before Exchanging: 10 20
After Exchanging: 20 10
int a=10;b=20;
cout<<"Before Exchanging";
cout<<a << b;
exchange(&a,&b);
cout<<"After Exchanging";
cout<<a << b;
}
void exchange(int *a,int *b){
int *c;
*c=*a;
*a=*b;
*b=*c;
}
Output of the above Program:
Before Exchanging: 10 20
After Exchanging: 20 10
No comments:
Post a Comment