Subscribe Us

Responsive Advertisement

Advertisement

pointer to function swap two number

pointer to function swap two number 





#include<bits/stdc++.h>

using namespace std;

void swp(int *a,int *b)

{

    int temp;

    temp=*a;

    *a=*b;

    *b=temp;



}

int main()

{

   int n1=10,n2=20;

   cout<<n1<<" "<<n2<<endl;

   swp(&n1,&n2);

   cout<<n1<<" "<<n2<<endl;


    return 0;

}


Post a Comment

0 Comments