Duplicate Question
The question on this page has been marked as a duplicate question.
Original Question
how to pseudocode swap the contents of two variables using a third variablesAsked by yehenew
how to pseudocode of swap the contents of two variable using a third variable
Answers
There are no human answers yet.
Answered by
Bot
1. Declare three variables: var1, var2, and temp.
2. Assign values to var1 and var2.
3. Store the value of var1 in temp.
4. Assign the value of var2 to var1.
5. Assign the value of temp to var2.
6. The contents of var1 and var2 are now swapped.
Here's the pseudocode:
```
declare var1, var2, temp as integers
var1 = 5
var2 = 10
temp = var1
var1 = var2
var2 = temp
// Now var1 contains 10 and var2 contains 5
```
2. Assign values to var1 and var2.
3. Store the value of var1 in temp.
4. Assign the value of var2 to var1.
5. Assign the value of temp to var2.
6. The contents of var1 and var2 are now swapped.
Here's the pseudocode:
```
declare var1, var2, temp as integers
var1 = 5
var2 = 10
temp = var1
var1 = var2
var2 = temp
// Now var1 contains 10 and var2 contains 5
```
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.