swap using third variable

Solutions on MaxInterview for swap using third variable by the best coders in the world

showing results for - "swap using third variable"
Emely
25 Feb 2019
1// SWAPPING WITHOUT USING THIRD VARIABLE
2#include<stdio.h>  
3 int main()    
4{    
5int a=10, b=20;      
6printf("Before swap a=%d b=%d",a,b);      
7a=a+b;//a=30 (10+20)    
8b=a-b;//b=10 (30-20)    
9a=a-b;//a=20 (30-10)    
10printf("\nAfter swap a=%d b=%d",a,b);    
11return 0;  
12}   
Aarón
02 Feb 2020
1// SWAP USING THIRD VARIBLE
2#include <stdio.h> 
3int main()
4{
5int var1, var2, temp; 
6printf("Enter two integersn");
7scanf("%d%d", &var1, &var2);
8printf("Before SwappingnFirst variable = %dnSecond variable = %dn", var1, var2);
9temp = var1;
10var1 = var2;
11var2 = temp;
12printf("After SwappingnFirst variable = %dnSecond variable = %dn", var1, var2);
13return 0;
14}
Luca
27 May 2017
1//The code for a function to Swap two number with a temporary variable is as follows
2#include<stdio.h>
3
4void swapping(int, int);  //function declaration
5int main()
6{
7    int a, b;
8
9    printf("Enter values for a and b respectively: \n");
10    scanf("%d %d",&a,&b);
11
12    printf("The values of a and b BEFORE swapping are a = %d & b = %d \n", a, b);
13
14    swapping(a, b);      //function call
15    return 0;
16}
17
18void swapping(int x, int y)   //function definition
19{
20    int third;
21    third = x;
22    x    = y;
23    y    = third;
24
25    printf("The values of a and b AFTER swapping are a = %d & b = %d \n", x, y);
26}
queries leading to this page
swap two variables without temporary variableswap two variablesswap variableswap of two numbers without using third variableswapping withour third variableswap to numers without 3rd variableswap a b value without third variableswapping variablesswaping two values without use of 3rd variableprogram swaping without using 3rd variableswap w 2fo third variableswaping two variablesswap values of two variablesswap two variables using third variablehow to swap without using third variableswap numbers without third variableswap two number without using third variableswap the value of two variables without using third variable in three different ways swap elements without using an extra variablehow to swap two variablesswap two values without third variableswap using third variable scalerhow to swap values without using third variableswap 2 no without third variableswap using third variableswap two values without third variable 3fswap no without using third variablehow to swap 2 variablesswapping of 2 variables without using third variable swap without using third variableswapping with two variableshow to swap 2 variables without 3rd variablehow to swap 2 variables without using a 3rdswap using third variable scalarhow to swap 2 values without using 3rd variableswap without using third variable and logical operatorsswap wuthout using extra variableswap two numbers without using third variableswap 2 variables without using 3rd variableswap a number without using a third variable data structureswap variables without third variableswap values between two variablesswapping variables without third variableswap two variables without using nother variableswap two variables without using the third variableswapping 2 variablesswap two numbers without using temportary variableswap the number without using third variableswapping two numbers without third variablehow do you swap two variables without a third variableswap 2 variables using 3rd variablehow to swap variables without using a third variableswapping without 3rd variableswaping without thirld variable usehow do you swap two numbers without using the third variableswap field of two variables without using a thirdswap vaules of two variables without using thord variablehow to swap 2 variables inwrite a function to swap two variables without using the third variableswap 2 integers without using temporary variableto swap two numbers without using third variableswapping without using third varswap to variables without using third in c 2b 2bcreate a function to swap the values of two variables swappng two variable without using third variableswap w numbers without using third variableswapping 2 variables without using 3rdswapping two variablesswap 2 variable without 3without using third variable swappingswap two numbers without third variableswap using two variablesswap two variables without using any extra variablesswap a variable without third variableusing swapping to switch variableshow to swap two numbers without third variable swapping using 3 varaiblesswapping using third varibleswap two variables without using third variablehow to swap two numbers without using a third variableswap two variables without using the third swap 2 numbers without using 3rd variableshow to swap two numbers without variableswapping without using third variableswap 2 numbers without using 3rd variableswap program without using third variablewrite a function swapv 28 29 to swap the values of two variables write a program to swap values of two variables without using third variableswap of two numbers using third variableswapping variables explainfastest way to swap two variablesswap without temporary variableswap numbers without using third variablehow to swap two numbers without using third variablehow to swap 2 numbers without 3rd variableswap two number without 3rd variabelswapping variable without using thirdswap values of two variables without using third variableswap using 2 variablesswap value without third variable2 variables swap without using 3rd variableswap a number without using a third variabeswap two numbers with out using third variable what use logicswapping of 2 numbers without using third variableswapping variables without using thirdswap without third variablehow to swap to variables without using thirdswapping of two variables without using third variableswap without extra variableprogram to swap two numbers without using third variableswap two variables without third variableswap number without thired variableswap two no without using third variableswapping without using 3rd variablehow to swap two variables without using third variablehow will you swap two variables without using a third variableswap values without using third variablehow do you swap two numbers without using the third variable 3fswap without variableswap two numbers without using a third variablehow to swap no when number 1 is less than other without using third variableswapping two values without third variableswap using third variable