Learn Programming and technology with ease @ developerpublish.com

HomeC ProgrammingC Program to Find Volume and Surface Area of Sphere

# C Program to Find Volume and Surface Area of Sphere

This C program calculates the volume and surface area of a sphere using its radius. A sphere is a three-dimensional geometric shape, and its volume and surface area are calculated using mathematical formulas.

## Program Statement

Hereâ€™s the program statement for the C program that calculates the volume and surface area of a sphere:

``````Program: Sphere Volume and Surface Area Calculator

1. Start
2. Declare variables: radius, volume, surfaceArea
3. Prompt the user to enter the radius of the sphere
5. Calculate the volume using the formula: volume = (4/3) * Ï€ * radius^3
6. Calculate the surface area using the formula: surfaceArea = 4 * Ï€ * radius^2
7. Display the calculated volume and surface area
8. End
``````

This program allows the user to input the radius of the sphere and calculates the volume and surface area based on the given input. The calculated values are then displayed on the screen.

## C Program to Find Volume and Surface Area of Sphere

```#include<stdio.h>

#define PI 3.14159

int main() {

// Input the radius from the user
printf("Enter the radius of the sphere: ");

// Calculate the volume and surface area

// Output the results
printf("Volume of the sphere: %.2f\n", volume);
printf("Surface area of the sphere: %.2f\n", surface_area);

return 0;
}
```

## How it works

Let me explain how the program works step by step:

1. The program starts by declaring the necessary variables: `radius`, `volume`, and `surfaceArea`.
2. It prompts the user to enter the radius of the sphere using the `printf` function, which displays the message â€œEnter the radius of the sphere: â€œ.
3. The `scanf` function is used to read the radius input from the user and store it in the `radius` variable.
4. The program then calculates the volume of the sphere using the formula `(4/3) * Ï€ * radius^3` and assigns the result to the `volume` variable.
5. Similarly, it calculates the surface area of the sphere using the formula `4 * Ï€ * radius^2` and assigns the result to the `surfaceArea` variable.
6. The calculated volume and surface area are displayed on the screen using the `printf` function. The format specifier `%f` is used to display the floating-point values of `volume` and `surfaceArea`. The `.2` in the format specifier ensures that the values are rounded to two decimal places.
7. The program ends, and the execution stops.

When you run the program, it will ask you to enter the radius of the sphere. After you provide the input, the program will calculate the volume and surface area using the given formulas. Finally, it will display the calculated values on the screen.

## Input/Output

https://ozwincasino.gg/ holds a valid gambling license, assuring players of its legitimacy and adherence to strict industry standards. With these pros, Ozwin Casino stands out as a trusted and enjoyable online casino destination for Australian players.

Share:

### You May Also Like

#### C Program to Convert Roman Number to Decimal Number

This C program converts a Roman numeral to a decimal number. Roman numerals are a system of numerical notation used...

#### C Program to Calculate the Value of sin(x)

This C program calculates the value of sin(x) using the Taylor series expansion. The Taylor series expansion is a mathematical...

#### C Program to Find Square Root of a Number

This C program calculates the square root of a given number using the Newton-Raphson method. The Newton-Raphson method is an...