Q:

Program to find the surface area of cuboid

belongs to collection: Basic Programs

0

Explanation

In this program, we have a cuboid with some length, width and height. We need to find its Surface Area.

A cuboid is a three-dimensional geometrical figure/container having six rectangular surfaces with the different sum of dimensions (length, width, and height) where every two opposite faces are of equal length width and height.

Formula

 

Surface Area Of  Cuboid = 2lw + 2lh + 22hw = 2( lw + lh + hw ).  

l is length, w is width and h is height.  

Algorithm

  1. Define values for all dimensions.
  2. Use these values in the given formula.
  3. Print the Surface Area of Cuboid.

Complexity

O(1)

Input:

l2w = 3h = 5

where l = lengthw = width and h = height.  

Output:

Surface Area OfCuboid = 2 * (l * w+ w * h + h * l)
                      = 2 * (2 * 3 + 3 * 5 + 5 * 2)
                      = 62.00000

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Python

l = 2  
w = 3  
h = 5  
surfacearea =2*( l *w  + w* h + h*l)  
print("Surface Area of Cuboid is : ");  
print (surfacearea);  

 

Output:

Surface Area of Cuboid is:  62

 

C

#include<stdio.h>  
                   int main()   
                   {  
                       float   l , w, h, surfacearea;  
                       l= 2;   
                       w = 3;  
                       h = 5;  
                       surfacearea =2*( l *w  + w* h + h*l);  
                       printf("\n\n Surface Area of Cuboid is : %f", surfacearea);  
                       return (0);  
    }  

 

Output:

Surface Area of Cuboid is:  62.00000

 

JAVA

public class test1   
{    
public static void main (String args[])   
 {   float  l, w, h,surfacearea;       
     l = 2;  
     w =3;  
     h = 5 ;  
    surfacearea  = 2*( l *w  + w* h + h*l);  
     System.out.println ("Surface Area of Cuboid is:  ");  
     System.out.println(surfacearea);  
}}  

 

Output:

Surface Area of Cuboid is:  62.0

 

C#

using System;  
class Program  
{   static void Main()   
    {   float  l,  w, h, surfacearea;  
       l  = 2;  
      w = 3;   
       h =5;   
       surfacearea = 2*( l *w  + w* h + h*l);  
        Console.WriteLine("Surface Area of Cuboid  is:"+surfacearea);  
    }}  

 

Output:

Surface Area of Cuboid is:  62

 

PHP

<?php  
$l = 2;  
$w = 3;  
$h =  5;  
$surfacearea = 2*( $l  * $w  + $w *$h + $h * $l);  
echo("Surface Area of Cuboid is  = ");  
echo($surfacearea);  
?> 

 

Output:

Surface Area of cuboid is  = 62

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Program to find the surface area of the cylinder... >>
<< Program to find the surface area of a cube...