English

Write an algorithm that accepts four numbers as input and finds the largest and smallest of them. - Computer Science (Python)

Advertisements
Advertisements

Question

Write an algorithm that accepts four numbers as input and finds the largest and smallest of them.

Short/Brief Note
Advertisements

Solution

Input first number
Input second number
Input third number
Input fourth number

Set lst = [ first , second, third , fourth ]
Sort the lst
lst.sort( )

Print greatest number is lst [ -1 ]
Print smallest number is lst [ 0 ]
shaalaa.com
Representation of Algorithms
  Is there an error in this question or solution?
Chapter 4: Introduction to Problem Solving - Exercise [Page 84]

APPEARS IN

NCERT Computer Science [English] Class 11
Chapter 4 Introduction to Problem Solving
Exercise | Q 10. | Page 84
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×