In an interview I was asked to write an efficient program such that for each integer value given, a function is called.
For example: if user enters 1 then function one will get executed if user enters 5 then function five gets executed and so on..
I was not able to come up with an efficient idea, like we can't use an if statement for checking the value entered and then executing the corresponding functions.
Is there any way we can do this in an efficient manner?
switch-case? Or perhaps an array of function pointers? Also "efficient" in regards to what?