Flowchart for swapping two values using functions in python

Flowchart for swapping two values using functions in python

Week 3

  1. Develop a flowchart for swapping two values using functions.

Aim : To exchange two values using functions.

Algorithm:

    Step1: Start

   Step2: Declare the variables a, b, and read the inputs.

   Step3: Call the function swap(a,b)

   Step4: In swap function perform the following steps.

   t=a

  a=b

  b=t

   Step5: After that print Swapped numbers are : a    b

   Step6: End.

Flowchart for swapping two values using functions in python

Source Code:

a = int ( input ( ” enter your number a : “))

b = int ( input ( ” enter your number b : “))

# n2 = eval ( input ( ” enter your second number : “)) # in this you can take any types of user input

n1 = a

a = b

b = n1

print (” After swap the number b is : “,b)

print (” After swap the number a is : “,a)

INPUT:

enter your number a : 100

enter your number b : 200

OUTPUT:

After swap the number b is : 100

After swap the number a is : 200

Related Link:

Flowchart for swapping two values using functions in python

https://en.wikipedia.org/wiki/Swap_(computer_programming)

https://en.wikipedia.org/wiki/Algorithm

Leave a Comment

Your email address will not be published. Required fields are marked *