I'm trying to learn C, but currently stuck. I'm trying to get the same output as below, but I'm not sure how to round the last few decimals points in my code to get the same output below.
1. ENTER AN INTEGER
2. 5
3. DIAMETER: 10.000000
4. CIRCUMFERENCE: 31.415900
5. AREA: 78.539750
int main()
{
float num1, diameter, circumference, area;
printf("ENTER AN INTEGER\n");
scanf("%f", &num1);
diameter = 2 * num1;
circumference = 2 * 3.14159 * num1;
area = 3.14159 * (num1 * num1);
printf("DIAMETER: %f\n", diameter);
printf("CIRCUMFERENCE: %.6f\n", circumference);
printf("AREA: %.6f\n", area);
return 0;
}
The output of my result.
1. ENTER AN INTEGER
2. 5
3. DIAMETER: 10.000000
4. CIRCUMFERENCE: 31.415899
5. AREA: 78.539749