Write an algorithm to produce the product of the smallest tw

Write an algorithm to produce the product of the smallest two numbers from a set of four numbers a,b,c,d.

Solution

Step I

Take four values a,b,c,d

Step II

Identify the smallest number in a, b, c, and d

If a<b, then a=s, otherwise b=s

If s<c, then t=s, otherwise c=t

If t<d, then t=u, otherwiswe u=d

Hence u is the smallest number and t is the next smallest

Step III

product of u and t gives the smallest two numbers from a set of four numbers{a,b,c,d}

Write an algorithm to produce the product of the smallest two numbers from a set of four numbers a,b,c,d.SolutionStep I Take four values a,b,c,d Step II Identif

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site