I am beginner at programming and I am just writing a very simple program to return the solution of 23/5. My code is below:
float res  = 23/5;
printf("%.3f", res);
The expected answer is 4.6, however, the code outputs: 4.000.
I am beginner at programming and I am just writing a very simple program to return the solution of 23/5. My code is below:
float res  = 23/5;
printf("%.3f", res);
The expected answer is 4.6, however, the code outputs: 4.000.
 
    
     
    
    You are setting its value to an int
float res  = 23.0f/5.0f;
printf("%.3f", res);
