how can swap values of two veriable witout using third verable in c++???
how can swap values of two veriable witout using third verable in c++???
ma ishq-e-kainaat ma zanjeer ho saku
mujh ko hisar-e-zaat ke shar se rahai de
koi rae to do
suppose u have two variables a and b
agar a =5 aur b =3 ho to
a=a+b;
b=a-b;
a=a-b;
first a ki value 8 ho jay gi than a ki new value jo k 8 ho chuki hy us main ne b ko minus krny se a ki value b main store ho jay gi and than a main se b ko minus krny se means 8-5 se b ki value a main aa jay gi thts it
Ki likhan?
int a,b,temp;
temp = a;
a=b;
b=temp;
ye hota hai swapping
brother inn ko swap karney k buhat sarey tarqey hai do tarkey aap ko bataye gaye hain inn main say 2nd one main third variable use ho raha hai jab k ranja1 bahi nay teek kaha hai uss say value change ho jati hai phir mazeed yeh hai
aap inn operation ko use kar saktey hain
a = a + b
b = a - b
a = a - b
There are many ways to do this. Trivially replacing +- with */ will also do it.
a=a*b;
b=a/b;
a=a/b;
a=b-a+(b=a);
aap try karey i think
ager aap yeh use karey tu bhi ho sakta hai
use xor to swap
a = a^b
b= a^b
a= a^b
ایک طرف لمبی لمبی امیدیں
دوسری طرف کل نفس ذائقۃ الموت
Bookmarks