Computer Science, asked by ifthikar77, 10 months ago

write an algorithm for swapping of two variable without using third ( or temp) variable.​

Answers

Answered by rani49035
2

Explanation:

use this

let variable be x and y

x=x+y;. //x=2,y=3 new x is x+y=5

y=x-y;. // New y is 5-3=2

x=x-y. // new x is 5-2=3

hence both values get swapped

Answered by AskewTronics
1

Algorithm To swap the two number:

Explanation:

  1. Start
  2. Take the two number and save into a and b
  3. Then write "a=a+b-(b=a)"
  4. then Print the value of a and b

Algorithm Explanation :

  • The above algorithm is used to replace the two numbers without using the third variable.
  • In this, the expression will do that when the user prints the value of a and b, then he gets the replaced value.
  • The above algorithm is written in the English language because the algorithm is always written in the English language.

Learn More :

  • Algorithm : https://brainly.in/question/6038825
Similar questions