Monday, 6 February 2017

Basic OOP programme

#include<iostream>
using namespace std;

class cube{
public:
double L;
double b;
double h;
};

int main()
{
cube c1;
cube c2;
c1.L=10;
c1.b=20;
c1.h=30;

c2.L=40;
c2.b=50;
c2.h=60;

double vol=0;
vol=c1.L * c1.b * c1.h;

cout << "Volume of the cube 1 is"  << vol << endl;
vol=c2.L* c2.b * c2.h;

cout << "Volume of the cube2 is " << vol << endl;

return 0;
}

No comments:

Post a Comment