+ 1
How swap two number
4 odpowiedzi
+ 10
the code playground is quite large by now
you can search the word 'swap' and filter by any language available there
https://code.sololearn.com/cHv1C8jEO6Rk/?ref=app
https://code.sololearn.com/cbKT04Q8MRSm/?ref=app
+ 5
public class Program
{
public static void main(String[] args) {
int a = 52;
int b = 42;
a ^= b;
b ^= a;
a ^= b;
System.out.println(a);
System.out.println(b);
}
}
+ 1
thq,,, BT without use third variable means
0
we have to perform the program using only two variables X and Y and we can't use a temporary variable.
That is:supposed x=1,y=2 then we can shift value of X in temporary variable say Z and
put value of y in X and put value of z in y hence d no's will be interchanged
this is using third variable which Z in this example