C
Programming and Technical
Programming
Technical
Write a program in Swapping inc/c++ of two numbers in a single line only ?
Read Solution (Total 9)
-
- b=a+b-(a=b)
here b is subtracted from sum of a+b and b is assigned to a
for example:
if a=10,b=20
a+b=30
we are assigning b to a and subtracting it from a+b
so now the answer is a=20 and b=10. - 10 years agoHelpfull: Yes(12) No(1)
- b=a*b/(a=b);
- 10 years agoHelpfull: Yes(6) No(1)
- a=b+(a-(b=a))
- 10 years agoHelpfull: Yes(3) No(0)
- a=43 and b=23
- 10 years agoHelpfull: Yes(1) No(2)
- a^=b^=a^=b;
- 10 years agoHelpfull: Yes(1) No(0)
- a=a+b-(b=a);
- 9 years agoHelpfull: Yes(1) No(0)
- main(){
int a,b;
b=a+b-(a=b);
} - 9 years agoHelpfull: Yes(1) No(0)
- int a=10,b=20
a=a+b-(b=a); - 9 years agoHelpfull: Yes(0) No(0)
- temp=a,a=b,b=temp;
- 8 years agoHelpfull: Yes(0) No(0)
C Other Question