I’m going to assume that by “button pressed” you either mean the last button pressed, or you are using “radio” buttons, where only one stays pressed, and pops out when another is pressed.
There are a number of ways to do this, but I think some are better than others.
You could have 48 button callbacks, each one setting a variable indicating the button was pressed.
When the slider is moved, it could use this variable as an index into a table with the label widget pointers.
I would call this the hard way.
The buttons could all call one callback. In that callback you search a table of button widget pointers to find which one was pressed, and store the index. The index could also reference a table of label widgets that the slider would use.
This is ok, but needs a table search each time a button is pressed.
The following would be my choice, as there is very low overhead, although searching a 48 item table whenever a human action occurs is not many cycles.
The buttons could all call one callback. In that callback you read the widget’s user-data. You’ve previously stored something in the user-data which you retrieve and store in a global variable. This could either be an index as in the above example, or the label widget pointer itself.