write an algorithm for swapping of two variable without using third ( or temp) variable.
Answers
Answered by
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
1
Algorithm To swap the two number:
Explanation:
- Start
- Take the two number and save into a and b
- Then write "a=a+b-(b=a)"
- 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
CBSE BOARD X,
5 months ago
Hindi,
5 months ago
Physics,
10 months ago
Chemistry,
10 months ago
English,
1 year ago