Flowchart for swapping two values using functions in python


Flowchart for swapping two values using functions in python

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 :The function perform the following steps.

  t=a

  a=b

  b=t

   Step5: print Swapped numbers are: a    b.

   Step6: End.

Flowchart for swapping two values using functions in python

Source Code for swapping values

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

Have any Question or Comment?

Leave a Reply

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

Domain & free Hosting

Categories

You have successfully subscribed to myprogrammingschool

There was an error while trying to send your request. Please try again.

My Programming School will use the information you provide on this form to be in touch with you and to provide updates and marketing.