Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


float setting the number of decimal places

piczimpiczim Member Posts: 11
I am trying to find out when using float in a calculation how to set the number of decimal places. For example my code below

int main()
float x=123.0;
float y=69.0;
float answer=y*x;
printf("the answer is %f

This returns an answer 8487.0000 I would like it not to show all the decimal places. However if the sum has decimal places I would like to select the number of decimal places shown



Sign In or Register to comment.