Compiled Function in a file

Today I am given an assignment to find the zeroes of a function using Newton-Raphson method. Till now, the input I gave to a program was data. But now the function (whose zeroes are to be calculated) is also an input.

Is there a way where I can compile and build a function into a file and during execution of my program open the file and run the machine-language code in it and get the return value?

No, here is no straight way (like in scripting languages - JS, PHP or Python). So you are to use some math expression parsing - and if you are not going to do this on your own, you are to find any suitable library.

Though you'd better read your assignment once more. Perhaps you are to use function of some specific type changing only its coefficients?

It is suspicious that you are required to implement parsing of arbitrary math expression...