Write a program to show swap of two numbers without using third variable.


#include<stdio.h>  
 int main()    
{    
int a=10, b=20;      
printf("Before swap a=%d b=%d",a,b);      
a=a+b;//a=30 (10+20)    
b=a-b;//b=10 (30-20)    
a=a-b;//a=20 (30-10)    
printf("\nAfter swap a=%d b=%d",a,b);    
return 0;  
}   

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
code for swapping two numbers Write a program to swap two numbers using a temporary variable and display its output swapping two numbers with third variable Program to swap two numbers without using 3rd variable. using bitwise Program to swap two numbers without using 3rd variable. swapping two numbers without using third variable program to swap two numbers 2, 3 swap the numbers using third variable swap to numers without 3rd variable Define two numbers and swap values Swap numbers without using third variable. Write a code to swap 2 number without using a 3rd variable? swap 2 numbers without using 3rd variable ways of swap two numbers 12. Write a program to swap two numbers defining a function swap( ). how to swap two numbers without using a third variable swap numbers without using third variable algorithm to swap two numbers without using third variable Write a program in C to swap two numbers without using a third variable. swapping numbers without using 3rd variable Write a program to swap two numbers without using a third/temporary variable Write a program to swap two integer values without using a third variable. how to swap 2 numbers without 3rd variable swap 2 numbers without 3rd variable swap 2 numbers without using 3rd variables swapping of two numbers without using third variable program to swap two numbers without using third variable swap program without using third variable Write a program in C to swap two numbers without using third variable. Write a program with a function named swap() that takes input in two variables a and b, and swaps their values programming questions like swap 2 numbers without 3rd variable Write an assemply program swap two numbers write a program to swap two numbers Write a program to input two unequal numbers. Display the numbers after swapping their values in the variables without using a third variable. Write a Program to swap values Write a program to swap them without using third variables. A = 2, B = 8 Write a program to swap them without using third variables. write a program to swap values of two variables with using third variable write a program to swap values of two variables program to swap two numbers swap two numbers without using third variable Write a program to swap values of two variables with and without using third variable. to swap the values of two integer numbers a and b entered by the user, and display the new numbers to the user. Do this with using a third variable to swap the values of two integer numbers a and b entered by the user, and display the new numbers to the user. Do this with and without using a third variable swap two numbers without third variable Create a function called swap that swaps the value of two integers. It should work in-place, actually modifying the integers how to swap numbers without using third variable Write a code for swapping of two numbers without using the third variable ? 1. Write a program in C++ to swap two numbers. Sample Output: Swap two numbers : swap two numbers without using third variable theory Swap the values of 2 given variables, without using a third one. Write a program to swap two integer number without using third variable Swap two numbers without using a third variable ( All possible ways ). swping two numbers Swapping of two numbers without using third variable (Take input from user) #include&lt;stdio.h&gt; int swap(int *a, int *b) { *a = *a + *b; *b = *a - *b ; *a = *a - *b ; ' } int main() Write a program to swap two numbers without using temporary/third Variable. how to swap variables without using a thid variable in c++ swap value without third variable swapping of two numbers a+b- (a=b) how to two value interchange in programming language how to swap two numbers without third variable c++ swap values without using third variable swap values without using third variable Write a program to show swap of two numbers without using third variable.
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source