Previous Next
0 / 20
Module DEMO-32-89DEMO-C-32

Volume of a Sphere

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Write a program that calculates the volume of a sphere given its radius r.

Use the formula: Volume = (4/3) * PI * pow(r, 3). Use 3.14159 for PI.

Target difficulty: Easy

Constraints

r >= 0

Input Format

A single floating-point number r.

Output Format

The volume formatted to 2 decimal places.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
1.0
4.19
(4/3) * PI * 1.0^3 = 1.333 * 3.14159 * 1.0 = 4.19
Sample #2
Public sample
3.0
113.10
(4/3) * PI * 3.0^3 = 1.333 * 3.14159 * 27.0 = 113.10
Sample #3
Public sample
5.0
523.60
(4/3) * PI * 5.0^3 = 1.333 * 3.14159 * 125.0 = 523.60
Sample #4
Public sample
10.0
4188.79
(4/3) * PI * 10.0^3 = 1.333 * 3.14159 * 1000.0 = 4188.79

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings