Important Notice:

Exchange Values of Two Variables

Exchange Values of Two Variables

4 views 1 min read

Exchange Values of Two Variables (दो Variables के Values को Exchange करना ):- Question:- Write an algorithm and flowchart to exchange the values of two variables.

Example: 

Before Exchange:
A = 10
B = 20

After Exchange:
A = 20
B = 10

Logic / Explanation

TEMP = A → Store the value of A temporarily.
A = B → Copy the value of B into A.
B = TEMP → Copy the original value of A into B.

solution:- Algorithm:-

  1. Start
  2. Input values of A and B.
  3. Set TEMP = A.
  4. Set A = B.
  5. Set B = TEMP.
  6. Display the exchanged values of A and B.
  7. Stop

Flow chart :-

Explanation:-

 

Related Notes