C program to find volume and surface area of a cuboid; Through this tutorial, we will learn how to find volume and surface area of a cuboid using standard formula and function in c programs.
Programs to Find Volume and Surface Area of a Cuboid in C
- C Program to Find Volume and Surface Area of a Cuboid using Standard Formula
- C Program to Find Volume and Surface Area of a Cuboid using Function
C Program to Find Volume and Surface Area of a Cuboid using Standard Formula
/* C Program to find Volume and Surface Area of a Cuboid */
#include <stdio.h>
int main()
{
float length, width, height;
float SA, Volume, LSA;
printf("\nPlease Enter Length of a Cuboid :- ");
scanf("%f",&length);
printf("\nPlease Enter Width of a Cuboid :- ");
scanf("%f", &width);
printf("\nPlease Enter Height of a Cuboid :- ");
scanf("%f", &height);
SA = 2 * (length * width + length * height + width * height);
Volume = length * width * height;
LSA = 2 * height * (length + width);
printf("\n The Surface Area of a Cuboid = %.2f\n",SA);
printf("\n The Volume of a Cuboid = %.2f\n",Volume);
printf("\n The Lateral Surface Area of a Cuboid = %.2f\n",LSA);
return 0;
}
The output of the above c program; as follows:
Please Enter Length of a Cuboid :- 10 Please Enter Width of a Cuboid :- 5 Please Enter Height of a Cuboid :- 15 The Surface Area of a Cuboid = 550.00 The Volume of a Cuboid = 750.00 The Lateral Surface Area of a Cuboid = 450.00
C Program to Find Volume and Surface Area of a Cuboid using Function
/* C Program to find Volume and Surface Area of a Cuboid */
#include<stdio.h>
float SurVolLet(float length,float height,float width)
{
float SA, Volume, LSA;
SA = 2 * (length * width + length * height + width * height);
Volume = length * width * height;
LSA = 2 * height * (length + width);
printf("\n The Surface Area of a Cuboid = %.2f\n",SA);
printf("\n The Volume of a Cuboid = %.2f\n",Volume);
printf("\n The Lateral Surface Area of a Cuboid = %.2f\n",LSA);
}
int main()
{
float length, width, height;
printf("\nPlease Enter Length of a Cuboid :- ");
scanf("%f",&length);
printf("\nPlease Enter Width of a Cuboid :- ");
scanf("%f", &width);
printf("\nPlease Enter Height of a Cuboid :- ");
scanf("%f", &height);
SurVolLet(length, height, width);
return 0;
}
The output of the above c program; as follows:
Please Enter Length of a Cuboid :- 5 Please Enter Width of a Cuboid :- 4 Please Enter Height of a Cuboid :- 10 The Surface Area of a Cuboid = 220.00 The Volume of a Cuboid = 200.00 The Lateral Surface Area of a Cuboid = 180.00