employer cover photo
employer logo
employer logo

Intrepid Pursuits

Is this your company?

Intrepid Pursuits Interview Question

Given 3 integers how do you find the middle number?

Interview Answers

Anonymous

Aug 4, 2017

func midNum(int a, int b, int c) { Int hi, lo If a>b: hi = a lo = b Else hi = b lo = a Return c > hi ? hi : (c < lo) ? lo : c }

2

Anonymous

May 8, 2017

Put the integers in a array and sort

Anonymous

Jul 28, 2017

var num1 = 24 var num2 = 6 var num3 = 64 var array = [num1, num2, num3] array.sort() var middleNum = array[array.count/2] print("The middle number is \(middleNum)")*/