HomeC ProgrammingC Program to Find Volume and Surface Area of a Cube

C Program to Find Volume and Surface Area of a Cube

In this C program, we will calculate the volume and surface area of a cube. A cube is a three-dimensional shape with all sides equal in length. The volume of a cube is the measure of space it occupies, while the surface area is the total area of all its faces. By using a few simple mathematical formulas, we can easily compute these values.

Problem statement

Write a C program to calculate the volume and surface area of a cube. The program should prompt the user to enter the length of the cube’s side, and then display the computed volume and surface area.

C Program to Find Volume and Surface Area of a Cube

#include <stdio.h>

int main() {
    float side, volume, surfaceArea;

    printf("Enter the length of the cube's side: ");
    scanf("%f", &side);

    volume = side * side * side;
    surfaceArea = 6 * side * side;

    printf("Volume of the cube: %.2f\n", volume);
    printf("Surface area of the cube: %.2f\n", surfaceArea);

    return 0;
}

Input\Output

C Program to Find Volume and Surface Area of a Cube

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

This C program calculates the volume and surface area of a sphere using its radius. A sphere is a three-dimensional...
This C program converts a Roman numeral to a decimal number. Roman numerals are a system of numerical notation used...
This C program calculates the value of sin(x) using the Taylor series expansion. The Taylor series expansion is a mathematical...