C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Program to find the surface area of a cubeExplanationIn 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 ) FormulaSurface Area Of Cube = 6( a × a ) a (side) = length=breadth=height Algorithm
ComplexityO(1) SolutionPythonl =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 JAVApublic 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#
|