Only 2 houses after the comma

3

I need the final result to show the whole number and 2 boxes after the comma.

Can you filter, say so, not to show all decimal places?

#include <stdio.h>
#include <math.h>

int main()
{
    float r, resp; // declara variavel 

    printf("\n  Digite o valor do raio: "); // entrada do valor do raio
    scanf("%f",&r); // le entrada

    resp = pow (r,3); //calcula area 
    resp = resp * 3.14159; //calcula area
    resp = (resp * (4.0 / 3.0)); //calcula area

    printf("\n\n  VOLUME = %f\n\n  ",resp); //exibe resultado em tela

    return 0;
}

Example

I enter with value 3, it outputs 113.097237 , but I need to output only 113.09 .

    
asked by anonymous 07.12.2016 / 22:41

1 answer

4

If you just need to print and do not calculate with this value you can later:

printf("\n\n VOLUME = %.2f \n\n",  resp);
    
07.12.2016 / 22:45