Is there a way to get the users input and then use that to decide what the precision of the outputted number should be?
What I mean is that I have a function to get the precision that the user wants and then I would want to be able to use that inputted number to decide how many decimal places should be shown. Normally when you are creating the program, you can decide it like this: printf("The number is: %0.2f", number);
, but can that %0.2f
also be dynamically changed so the user can decide if it should be 0.2, 0.3, 0.4, etc?