C Program to Find Volume and Surface Area of Cuboid
Write a C program to find the volume of cuboid. Write a c program to find the surface area of cuboid.
A cuboid is a 3D object made up of 6 Rectangles. All the opposite faces are equal in length, breadth and thus in area.
Here is the source code of C program to find the volume cuboid and calculate surface area of cuboid.
A cuboid is a 3D object made up of 6 Rectangles. All the opposite faces are equal in length, breadth and thus in area.
C Program to Find Surface Area and Volume of Cuboid
Surface area Formula to find surface area of cuboid: SA=2lw+2lh+2hw Volume Formula to find volume of cuboid: Volume of cuboid = length × breadth × height
Example:
Input : length = 2 breadth = 3 height = 4 Output : Total Surface Area = 52 Volume of cuboid = 2 x 3 x 4 = 24This code finds out the volume and surface area of cuboid given the length, breadth(width) and height of cuboid.
Here is the source code of C program to find the volume cuboid and calculate surface area of cuboid.
/* Aim: C code to find the Surface area and volume of cuboid */
#include<stdio.h>
int main()
{
float l,b,h,s,v;
printf("\n Enter length of cuboid :");
scanf("%f",&l);
printf("\n Enter breadth of cuboid :");
scanf("%f",&b);
printf("\n Enter height of cuboid :");
scanf("%f",&h);
s=2*(l*b+b*h+b*h);
v=l*b*h;
printf("\n The surface area of cuboid is '%f'",s);
printf("\n \n The volumer of cuboid is '%f' \n \n",v);
return 0;
}
Output:
Enter length of cuboid :12 Enter breadth of cuboid :4 Enter height of cuboid :5 The surface area of cuboid is '176.000000' The volume of cuboid is '240.000000'