Monday, 23 July 2018

11C Prg-8 Sort 3 numbers without using conditional or looping statments


Algorithm:

#Program
x = int(input("Input first number: ")) y = int(input("Input second number: ")) z = int(input("Input third number: ")) small = min(x, y, z) large = max(x, y, z) midd = (x + y + z) - small - large print("Numbers in sorted order: ",small,midd,large)

Example:

Input first number: 5
Input second number: 7
Input third number: 6
Numbers in sorted order:  5 6 7

No comments:

Post a Comment