could anyone help with this problem please

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

could anyone help with this problem please You are given three integer numbers: a, b and c. Write a function:int median3(int a,int b,int c); which returns the second largest number x, among sequence (a,b,c). For example: for median3(4, 2, 6) the correct answer is 4, for median3(1, 2, 2) the correct answer is 2.

dilbar · Jun 28, 2010 7:20 PM · 8,093 views

1 Reply

what about this? ;-) int median3(int a, int b, int c) { int middle; if(a < b && a > c || a > b && a < c){ middle = a;} else if(b < a && b > c || b > a && b < c){ middle = b;} else{middle = c;}; return middle; }

ANS · Jun 29, 2010 1:15 PM

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion