Problem :
Sphere
Adapted by Neilor Tonin, URI
Brazil
Timelimit: 1
Brazil
Make a program that calculates and print the volume of a sphere given the radius (R) of the circle. The formula to calculate the volume is: (4/3) * pi * R3. For the purposes of this problem the value of pi is 3.14159.
Tip: Use (4/3.0) or (4.0/3) in your formula, because some languages (including C++) assume that the result dividing two integers is another integer. :)
Input
The input file contain an integer number.
Output
The output file will contain a message like the following example. Remember the space before and after the equal signal. The value must be printed with 3 digits after the decimal point.
| Sample Inputs | Sample Outputs |
| 3 | VOLUME = 113.097 |
| 15 | VOLUME = 14137.155 |
| 1523 | VOLUME = 14797486501.627 |
Solution:
#include <stdio.h> int main() { float R; double Formula; scanf("%f",&R); Formula=(4/3.0) * 3.14159 * (R*R*R); printf("VOLUME = %.3lf\n",Formula); return 0;}
No comments:
Post a Comment