C Program to Find Surface Area and Volume of a Cube


Lets write a C program to calculate Surface area, Volume and Lateral Surface area of a Cube.

Related Read:
Basic Arithmetic Operations In C

Formula To Calculate Surface Area, Volume and Lateral Surface area of a Cube

Note: If we know the length of any side of the cube, we can calculate the surface area and lateral surface area by using formula shown below.

Surface Area of a Cube
surface_area = 6 * (l * l);

Lateral Surface Area of a Cube
lateral_surface_area = 4 * (l * l);

Volume of a Cube
volume= l * l * l;

where l is value of length of any side of a cube.

The amount of space present inside the cube(3 dimensional cube) is called the volume of that cube.

Source Code: C Program to Find Surface Area and Volume of a Cube

  1.    
  2. #include < stdio.h >  
  3.   
  4. int main()  
  5. {  
  6.     float l, SA, volume, LSA;  
  7.   
  8.     printf("Enter length of any side of a cube\n");  
  9.     scanf("%f", &l);  
  10.   
  11.     SA     = 6 * (l * l);  
  12.     volume = l * l * l;  
  13.     LSA    = 4 * (l * l);  
  14.   
  15.     printf("Surface Area of the cube = %f\n", SA);  
  16.     printf("Volume of the cube = %f\n", volume);  
  17.     printf("Lateral Surface Area of the cube = %f\n", LSA);  
  18.   
  19.     return 0;  
  20. }  

Output 1:
Enter length of any side of a cube
3
Surface Area of the cube = 54.000000
Volume of the cube = 27.000000
Lateral Surface Area of the cube = 36.000000

Output 2:
Enter length of any side of a cube
5
Surface Area of the cube = 150.000000
Volume of the cube = 125.000000
Lateral Surface Area of the cube = 100.000000

C Program to Find Surface Area and Volume of a Cube



YouTube Link: https://www.youtube.com/watch?v=rqAH-E_dR0w [Watch the Video In Full Screen.]


For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

Leave a Reply

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