← Back to Kurakani

could anyone help with this problem please

Original 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
ANS Jun 29, 2010 1:15 PM
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; }
Login to join the conversation.

You might be interested in...

Latest Kurakani View all
Recent Classifieds View all
Upcoming Events View all
Service Providers View all
Ask Sajha AI Assistant