TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Program to find the surface area of a cube

Program to find the surface area of a cube on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph etc.

<< Back to PROGRAM

Program to find the surface area of a cube

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)


Solution

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

Next Topic#




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf