Computer Science, asked by sangi1985sahasam, 6 months ago

Write the algorithm and flowchart to swap two numbers using temporary variable​

Answers

Answered by Mehtasaab97
23

1:start.

2:read a,b,temp.

3.temp=a;

a=b;

b=temp;

4:print a,b.

5:stop

for flow chart use

oval shape for stop and start

rectangle for 3rd step

parrelogram for print and read

all should joined by arrows

Answered by SaurabhJacob
10

The Algorithm for swapping two numbers using a temporary variable is,

*numbering represents the steps

  1. Begin
  2. Read X and Y
  3. Show X and Y
  4. Store X to C ; C = X
  5. Transfer Y to X ; X = Y
  6. Transfer C to Y ; Y = C
  7. Show X and Y
  8. End

The Flowchart for the above problem is,

                                         Start

                                            ║

                                            ∨

                                  Read X and Y

                                            ║

                                            ∨

                                          C=X;

                                          X=Y;

                                          Y=C;

                                            ║

                                            ∨

                                  Print X and Y

                                            ║

                                            ∨

                                          Stop

Similar questions