+ 17

[ASSIGNMENT] Swapping Two Variables.

Write a program that swapping variables each other. For Example: Input: v1 = " first string" v2 = " second string" And the output : v2 = " first string" v1 = " second string" Try to slove in short as much as possible. 😊 Good luck.✌✌

16th Jan 2018, 12:38 PM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
25 Answers
17th Jan 2018, 3:02 PM
Mahmudul Hasan Fahim
Mahmudul Hasan Fahim - avatar
+ 15
16th Jan 2018, 2:56 PM
LukArToDo
LukArToDo - avatar
+ 15
https://code.sololearn.com/cCbmpAa4X4bB/?ref=app
16th Jan 2018, 4:08 PM
Justine Ogaraku
Justine Ogaraku - avatar
+ 7
https://code.sololearn.com/c2MIch983V19/?ref=app
16th Jan 2018, 1:23 PM
Louis
Louis - avatar
+ 6
16th Jan 2018, 12:53 PM
Akash Pal
Akash Pal - avatar
17th Jan 2018, 6:29 AM
Kartik
Kartik - avatar
17th Jan 2018, 12:35 PM
Cool Codin
Cool Codin - avatar
+ 6
x = 10 y = 1 ruby x,y = y,x
18th Jan 2018, 10:46 AM
Momo Belia
Momo Belia - avatar
19th Apr 2018, 6:21 PM
Neelarghya Kundu
Neelarghya Kundu - avatar
+ 5
Python: v1,v2 = v2,v1
17th Jan 2018, 12:11 AM
Luis Lopes
Luis Lopes - avatar
+ 5
Swapping without using 3rd variable https://code.sololearn.com/cq88vH4nFgOy/?ref=app
18th Jan 2018, 2:29 PM
...
20th Jan 2018, 6:28 PM
adam abdo
adam abdo - avatar
+ 5
https://code.sololearn.com/cWJOf0k182EA/?ref=app
23rd Jan 2018, 6:14 PM
Ayush Shukla
Ayush Shukla - avatar
11th Feb 2018, 5:23 PM
Jacob Snover
Jacob Snover - avatar
16th Jan 2018, 5:59 PM
bedawang
bedawang - avatar
+ 4
we can solve it without using third variable in python. following snippet shows the swapping of two variables. v1,v2 = v2,v1
16th Jan 2018, 6:41 PM
Pranayreddy
+ 4
#include<stdio.h> #include<conio.h> void main() { int a,b,c; printf("Enter a\n"); scanf("%d",&a); printf("Enter b\n"); scanf("%d",&b); printf("The values of a is %d and b is %d before swaping\n",a,b); c=a; a=b; b=c; printf("The values of a is %d and b is %d after swaping\n",a,b); getch(); } Output:
16th Jan 2018, 7:01 PM
surya.sachan
surya.sachan - avatar
+ 4
16th Jan 2018, 11:58 PM
Liza
Liza - avatar
+ 4
https://code.sololearn.com/c5Rs2Nuq0Ph8/?ref=app
19th Jan 2018, 4:41 AM
Esraa Mostfa
Esraa Mostfa - avatar