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 finds the Greatest Common Divisor (GCD) of two given numbers. Problem Statement Write a C program that...
This C program calculates the roots of a quadratic equation of the form ax^2 + bx + c = 0....
This C program allows you to find the length of a linked list, which is the number of nodes present...