• Language

    C

  • Description

    It allows the user to enter a value for one edge of a cube. The program calculates the surface area of one side of the cube, the surface area of the cube, and its volume.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    float cube_surface_area, one_edge, one_side_surface_area, volume;
    printf ("Enter the value of one edge: ");
    scanf ("%f", &one_edge);
    (void) getchar ();
    one_side_surface_area=one_edge*one_edge;
    cube_surface_area=one_side_surface_area*6;
    volume=one_edge*one_edge*one_edge;
    printf ("Value of cube surface area: %g\n", cube_surface_area);
    printf ("Value of one side surface area: %g\n", one_side_surface_area);
    printf ("Value of volume: %g\n", volume);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}