Otherwise you're looking at running the code through an interpreter of some sort, which could be as simple as using an existing interpreter similar to above, or writing a form of eval() that handles C code (not a task taken lightly).
Ultimately, I'd say that C probably isn't the correct choice of language if dynamic evaluation of code is a necessary feature.
root = tkinter.Tk()
buttons=[i for i in range(10)]
#If specific button is pressed, output "YES"
for num in buttons: