C++ Program to Compute Volume and Surface Area of Cube

Write C++ Program to Compute Volume and Surface Area of Cube

// CPP Program to Compute Volume and Surface Area of Cube

#include <iostream>

using namespace std;

int main()

{
   float side = 4;

   double area_cube;
   //cube area formula
   area_cube = 6 * side * side;

   double volume;
   //cube volume formula
   volume = side * side * side;

   cout << "Surface area of the cube having side " << side << " :--> " << area_cube;

   cout << "\nVolume of the cube having side " << side << " :--> " << volume;

   return 0;
}

Output:

Surface area of the cube having side 4.00 :--> 96.00
Volume of the cube having side 4.00 :--> 64.00

≪ Previous | Next ≫