Program for Volume and Surface Area of Cuboid

21 Jun, 2022
Cuboid is a 3-dimensional box-like figure represented in the 3-dimensional plane.Cuboid has 6 rectangled-shape faces. Each face meet another face at 90 degree each.Three sides of cuboid meet at same vertex.Since it is made up of 6 rectangle faces, it have length, width and height of different dimension. 
Examples :  
Input : 2 3 4
Output : Area = 24
         Total Surface Area = 52 
  

Input : 5 6 12
Output : Area = 360
         Total Surface Area = 324
 
Formulae :  
Area = l*w*h
Total Surface Area = 2*l*w + 2*w*h + 2*l*h
where l, h, w are length, height and width of
cuboid respectively.
 
C++
Java
Python3
C#
PHP
Javascript
// CPP program to find volume and// total surface area of cuboid#include <bits/stdc++.h>using namespace std; // utility functiondouble areaCuboid(double l, double h, double w){    return (l * h * w);} double surfaceAreaCuboid(double l, double h, double w){    return (2 * l * w + 2 * w * h + 2 * l * h);} // driver functionint main(){    double l = 1;    double h = 5;    double w = 7;    cout << "Area = " << areaCuboid(l, h, w) << endl;    cout << "Total Surface Area = "         << surfaceAreaCuboid(l, h, w);    return 0;}
// Java program to find volume and// total surface area of cuboid class GFG{    // utility function    static double areaCuboid(double l, double h,                                           double w)    {        return (l * h * w);    }     static double surfaceAreaCuboid(double l, double h,                                                double w)    {        return (2 * l * w + 2 * w * h + 2 * l * h);    }         // Driver code    public static void main (String[] args)    {        double l = 1;        double h = 5;        double w = 7;        System.out.println("Area = " + areaCuboid(l, h, w));        System.out.println("Total Surface Area = "                            + surfaceAreaCuboid(l, h, w));    }}// This code is contributed By Anant Agarwal.
# Python3 code to find volume and# total surface area of cuboid # utility functiondef volumeCuboid( l , h , w ):    return (l * h * w)     def surfaceAreaCuboid( l , h , w ):    return (2 * l * w + 2 * w * h + 2 * l * h) # driver functionl = 1h = 5w = 7print("Volume =" , volumeCuboid(l, h, w))print("Total Surface Area =", surfaceAreaCuboid(l, h, w)) #This code is contributed by "Sharad_Bhardwaj".
// C# program to find volume and// total surface area of cuboidusing System; class GFG {         // utility function    static double areaCuboid(double l, double h,                            double w)    {        return (l * h * w);    }     static double surfaceAreaCuboid(double l, double h,                                    double w)    {        return (2 * l * w + 2 * w * h + 2 * l * h);    }     // Driver code    public static void Main()    {        double l = 1;        double h = 5;        double w = 7;                 Console.WriteLine("Area = " + areaCuboid(l, h, w));        Console.WriteLine("Total Surface Area = "                        + surfaceAreaCuboid(l, h, w));    }} // This code is contributed By vt_m.
<?php// PHP program to find volume and// total surface area of cuboid // utility functionfunction areaCuboid($l, $h, $w){    return ($l * $h * $w);} function surfaceAreaCuboid($l, $h, $w){    return (2 * $l * $w + 2 * $w *                $h + 2 * $l * $h);} // Driver Code$l = 1;$h = 5;$w = 7;echo "Area = " ,     areaCuboid($l, $h, $w) , "\n";echo "Total Surface Area = ",      surfaceAreaCuboid($l, $h, $w); // This code is contributed by ajit?>
<script>// javascript program to find volume and// total surface area of cuboid  // Utility functionfunction areaCuboid( l,  h,  w){    return (l * h * w);} function surfaceAreaCuboid( l,  h,  w){    return (2 * l * w + 2 * w * h + 2 * l * h);} // Driver function     let l = 1;    let h = 5;    let w = 7;   document.write( "Area = " + areaCuboid(l, h, w) +"<br/>");   document.write("Total Surface Area = "         + surfaceAreaCuboid(l, h, w)+"<br/>");          // This code is contributed by todaysgaurav</script>
Output :  
Area = 35
Total Surface Area = 94
Time complexity : O(1) Auxiliary Space : O(1)
This article is contributed by Saloni Gupta . If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
jit_t
todaysgaurav
krishnav4
area-volume-programs
Geometric
School Programming
Geometric
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Program for distance between two points on earth
Optimum location of point to minimize total distance
Line Clipping | Set 1 (Cohen–Sutherland Algorithm)
Convex Hull | Set 1 (Jarvis's Algorithm or Wrapping)
Check whether a given point lies inside a triangle or not
Python Dictionary
Reverse a string in Java
Arrays in C/C++
Introduction To PYTHON
Interfaces in Java