Monday, 9 January 2012

Simple C++ programs to calculate the volumn of 2 cube

#include<iostream.h>
using namespace std;

class cube
{
            public:
                        double side;
                        double volume()
                        {
                                    return(side*side*side);
                        }
};
                       
int main()
{
            double volume1=0;
            cube c1,c2;
            cout << "Enter the lenght of the cube" << endl;
            cin >> c1.side;
            cout << "The volume of the cube is : " << c1.volume() << endl;
            c2.side=c1.side +2;
            cout << "The volume of the second cube is : " << c2.volume() << endl;
             return(0);
}

No comments:

Post a Comment