Answer to Question #188944 in C++ for zain ul abdeen

Question #188944

Q.write a program to swapp variables value. Note you cannot take third variable and implement it by making a class.


1
Expert's answer
2021-05-04T13:02:49-0400
#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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS