This week's book giveaway is in the Design forum. We're giving away four copies of Building Microservices and have Sam Newman on-line! See this thread for details.

Can anyone find the medium of a given input? Using this code I have tried but I failed But I think there�s a easy way of doing that, Medium means Input : 2 4 5 6 6 6 7 7 8 Considering on above number sequence the medium is 6 Please someone can figure this out leave a comment

[BPSouther: Added code tags] [ March 10, 2008: Message edited by: Ben Souther ]

If number of integers entered is an even number, then there will be two medians. If no. of integers entered is an odd number, then only one median we will have... [ March 18, 2008: Message edited by: agilemanoj kumar ]

Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)

Hamsagayathri Palanisamy
Ranch Hand

Joined: Mar 10, 2008
Posts: 44

posted

0

Originally posted by agilemanoj kumar:

If number of integers entered is an even number, then there will be two medians. If no. of integers entered is an odd number, then only one median we will have...

[ March 18, 2008: Message edited by: agilemanoj kumar ]

Hi agilemanoj, if the number of integers entered is even number,i think there is no two medians, For example: Integers entered are: 1 2 3 4 5 6 Then Median is: (3+4) /2 = 3.5 and if the integers entered are: 1 2 3 4 5 Median is: 3 I hope above one is median calculation and please correct me if i'm wrong.