0
a program to swap to numbers !!
without using third variable as well as array
4 odpowiedzi
+ 3
#include<iostream>
int main()
{
int a,b;
cout<<"enter two numbers";
cin>>a>>b;
a+=b;
b=a-b;
a-=b;
cout<<"after swapping \n";
cout<<"a="<<a<<"b=<<"b;
return 0;
}
+ 3
int a = 1;
int b = 2;
swap (a,b);
cout <<a <<b;
outputs 21
without a 3rd variable and an array as u asked
0
You can use simple logic
int a,b;
a=a+b;
b=a-b;
a=a-b;
for ex if a=4 and b=5
a=4+5;
b=9-5;
a=9-4;
0
Hello ayush,
Same procedure is I used above...