Skip to content
doubtly

1 answer

Best answer

This is a practical question so will try to understand the concept , the question said us to use swap function

This code is error free might only work with turbo C++ 


#include <iostream.h>
#include<conio.h>
void swap(float &x,float &y)
{
 float t=x;
 x=y;
 y=t;
 
}

int main()
{void swap(float &x,float &y);
float a,b;
cin>>a>>b;
cout<<"a="<<a<<"b="<<b<<endl;
swap(a,b);
cout<<"a="<<a<<"b="<<b<<endl;
 
}

We added a output for you to get it clearly 

image

Doubtly · 28 Oct 2022 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.