📜  立方体体积和表面积程序

📅  最后修改于: 2021-05-05 01:24:59             🧑  作者: Mango

多维数据集是在3维平面中表示的3维盒状图形。多维数据集具有6个正方形的相等面。每张脸以90度相遇。立方体的三个边在同一顶点相交。

立方体

例子:

Input : Side of a cube = 2
Output : Area = 8
         Total surface area = 24

Input : Side of a cube = 3
Output : Area = 27
         Total surface area = 54
C++
// CPP program to find area
// and total surface area of cube
#include 
using namespace std;
 
// utility function
double areaCube(double a)
{
    return (a * a * a);
}
 
double surfaceCube(double a)
{
    return (6 * a * a);
}
 
// driver function
int main()
{
    double a = 5;
    cout << "Area = " << areaCube(a) << endl;
    cout << "Total surface area = " << surfaceCube(a);
    return 0;
}


Java
// Java program to find area
// and total surface area of cube
 
class GFG
{
    // utility function
    static double areaCube(double a)
    {
        return (a * a * a);
    }
 
    static double surfaceCube(double a)
    {
        return (6 * a * a);
    }
     
    // Driver code
    public static void main (String[] args)
    {
        double a = 5;
        System.out.println("Area = "+areaCube(a));
        System.out.println("Total surface area = "
                           +surfaceCube(a));
    }
}
 
// This code is contributed by Anant Agarwal.


Python3
# Python3 code to find area
# and total surface area of cube
 
# utility function
def areaCube( a ):
    return (a * a * a)
 
def surfaceCube( a ):
    return (6 * a * a)
 
# driver function
a = 5
print("Area =", areaCube(a))
print("Total surface area =", surfaceCube(a))
 
# This code is contributed by "Sharad_Bhardwaj".


C#
// C# program to find area
// and total surface area of cube
using System;
 
class GFG {
     
    // utility function
    static double areaCube(double a)
    {
        return (a * a * a);
    }
 
    static double surfaceCube(double a)
    {
        return (6 * a * a);
    }
 
    // Driver code
    public static void Main()
    {
        double a = 5;
         
        Console.WriteLine("Area = " + areaCube(a));
        Console.WriteLine("Total surface area = "
                        + surfaceCube(a));
    }
}
 
// This code is contributed by vt_m.


PHP


Javascript


输出:

Area = 125
Total surface area = 150