Consider using an array of (value, function) pairs; search this table for a matching value then execute the corresponding function. (If the table is sorted by value, you can use bsearch() to search it.)