Q:

Program to find the surface area of a cube

belongs to collection: Basic Programs

0

Explanation

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

A cube is a three-dimensional geometrical figure/container having all its surfaces with equal sides (length, breadth, and height). We have six equal square(surfaces).

Surface Area of Cube = 6 (Surface area of one Square)

Total Surface Area Of Cube = 6( side × side )

Formula

 

Surface Area Of  Cube = 6( a  ×   a )   

a (side) = length=breadth=height  

Algorithm

  1. Define equal value for all sides of cube.
  2. Use these values in the given formula.
  3. Print the Surface Area of Cube.

Complexity

O(1)

Surface Area Of Cube = 6 ( a * a )

Input:

b = 5h = 5  

a (side) = length = breadth = height  

Output:

Surface Area Of Cube = 6 * 5 * 5=150.00000

All Answers

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

Python

l =5  
b = 5  
h = 5  
a=l=b=h  
surfacearea =6*(a*a)  
print("Surface Area of Cube is : ");  
print (surfacearea);  

 

Output:

Surface Area of Cube is: 150

 

C

#include<stdio.h>  
                   int main()   
                   {  
                       float  a , l , b, h, surfacearea;  
                       l= 5;   
                       b = 5;  
                       h = 5;  
                       a=l=b=h;  
                       surfacearea = 6*(a*a);  
                       printf("\n\n Surface Area of Cube is : %f", surfacearea);  
                       return (0);  
    }  

 

Output:

Surface Area of Cube is: 150.00000

 

JAVA

public class test1   
{    
public static void main (String args[])   
 {   float a, l, b, h, surfacearea;       
     l = 5;  
     b =5;  
     h = 5;    
     a=l=b=h;    
    surfacearea  = 6*(a*a);       
     System.out.println ("Surface Area of Cube is ");  
     System.out.println(surfacearea);  
}} 

 

Output:

Surface Area of Cube is 150.0000

 

C#

using System;  
class Program  
{   static void Main()   
    {   float a, l,  b, h, surfacearea;  
       l  = 5;  
       b= 5;   
       h =5;   
      a=l=b=h;  
       surfacearea =6*(a*a);  
        Console.WriteLine("Surface Area of Cube is:"+surfacearea);  
    }}  

 

Output:

Surface Area of Cube is:  150

 

PHP

<?php  
$l = 5.0;  
$b = 5.0;  
$h =  5.0;  
$a=$l=$b=$h;  
$surfacearea =6 *($a*$a);  
echo("Surface Area of cube is  = ");  
echo($surfacearea);  
?> 

 

Output:

Surface Area of cube is  = 150

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 cuboid... >>
<< Program to find the simple interest...