how to write pseudocode swap the content of two variables using a third variable
1. Declare three variables A, B and C.
2. Assign values to variables A and B.
3. Display the original values of A and B.
4. Assign the value of A to C.
5. Assign the value of B to A.
6. Assign the value of C to B.
7. Display the new values of A and B.
8. End.
Pseudocode:
```
DECLARE A, B, C AS INTEGER
SET A = 5
SET B = 10
DISPLAY "Original Values: A=", A, " B=", B
SET C = A
SET A = B
SET B = C
DISPLAY "New Values: A=", A, " B=", B
```
Output:
```
Original Values: A=5 B=10
New Values: A=10 B=5
```
To swap the content of two variables using a third variable, you can follow these steps:
1. Start by declaring three variables: `variable1`, `variable2`, and `temp`.
2. Assign the initial values to `variable1` and `variable2`.
3. Create a temporary variable (`temp`) and assign the value of `variable1` to it.
- `temp = variable1`
4. Assign the value of `variable2` to `variable1`.
- `variable1 = variable2`
5. Finally, assign the value of `temp` to `variable2`.
- `variable2 = temp`
Here's the complete pseudocode to swap two variables using a third variable:
```
Declare variable1, variable2, temp
Assign initial values to variable1 and variable2
temp = variable1
variable1 = variable2
variable2 = temp
```
Make sure to replace `variable1` and `variable2` with the actual variable names you want to swap.