Q.write a program to swapp variables value. Note you cannot take third variable and implement it by making a class.
#include<iostream>
using namespace std;
void swapp(int x,int y)
{
x=x+y;
y=x-y;
x=x-y;
cout<<"\nValues after swapping are x = "<<x<<" and y = "<<y;
}
int main()
{
int x,y;
cout<<"Enter the value of x ";
cin>>x;
cout<<"Enter the value of y ";
cin>>y;
swapp(x,y);
}
Comments
Leave a comment