"I keep getting error messages"
Then read the doc of the functions you use, in particular pay close attention to what the inputs and outputs are.
For this particular error:
Index exceeds the number of array elements (1).
Error in assigment03_pt01 (line 40)
it would be because you have created a variable named title, so title(z2) is no longer passing z2 to the title function but instead is indexing into your title variable.
With regards to sprintf vs fprintf, as Stephen says you can't swap one for the other and in any case they format text exactly the same way (hence the very similar names). You want sprintf. Read the documentation of the format string to customise the display to what you want. Perhaps you want %g instead of %f.
"(i dont know how i made it a variable though)"
Somewhere, you wrote