Read the length of the side of Cube from the user, and calculate the area of Cube.

Area of Cube formula: 6 x side2 or 6a2

Where, side (or a) is the length of the side (i.e., edge)

Program:

The source code to calculate the area of Cube is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.

// C program to calculate the area of Cube
#include <stdio.h>
float calcuateAreaOfCube(float side)
{
float result = 0.0F;
result = 6.0 * side * side;
return result;
}
int main()
{
float side = 0;
float area = 0;
printf("Enter the length of side: ");
scanf("%f", &side);
area = calcuateAreaOfCube(side);
printf("Area of Cube is: %f\n", area);
return 0;
}

Output:

RUN 1:
Enter the length of side: 2.4
Area of Cube is: 34.560001
RUN 2:
Enter the length of side: 10.23
Area of Cube is: 627.917358
RUN 3:
Enter the length of side: 12.0
Area of Cube is: 864.000000

Explanation:

In the above program, we created two functions calcuateAreaOfCube() and main(). The calcuateAreaOfCube() function is used to calculate the area of Cube based on the given side of Cube.

In the main() function, we read the value of the side of Cube from the user. Then we called the calcuateAreaOfCube() function to calculate the area of the Cube.

Read the length of the side of Cube from the user, and calculate the area of Cube.

Area of Cube formula: 6 x side2 or 6a2Where,

side(ora) is the length of the side (i.e.,edge)Program:The source code to calculate the area of Cube is given below. The given program is compiled and executed using GCC compile on UBUNTU 18.04 OS successfully.

Output:Explanation:In the above program, we created two functions

calcuateAreaOfCube()andmain(). ThecalcuateAreaOfCube()function is used to calculate the area of Cube based on the given side of Cube.In the

need an explanation for this answer? contact us directly to get an explanation for this answermain()function, we read the value of the side of Cube from the user. Then we called thecalcuateAreaOfCube()function to calculate the area of the Cube.