Sunday, June 6, 2021

program swap two numbers using function (POP) (157)

#include<iostream>

using namespace std;

void swap(int*,int*);

int main()

{

int n1,n2;

cout<<"please enter first number:";

cin>>n1;

cout<<"please enter second number:";

cin>>n2;

cout<<"after swaping the numbers:"<<swap(&n1,&n2)<<endl;

return 0;

}

void swap(int* n1, int* n2)

{

int sw;

sw=*n1;

*n1=*n2;

*n2=sw;

} 

No comments:

Post a Comment