C++ Exercises
C++ Program to calculate the volume and surface of the Rectangular Solid.
Let see the program to calculate the volume and surface of the Rectangular Solid.
/* to calculate the volume of the Rectangular Solid. */ #include <iostream> using namespace std; int main() { double length,width,height,volume; cout<<"Enter length of Rectangular Solid :"; cin>>length; cout<<"Enter width of Rectangular Solid :"; cin>>width; cout<<"Enter length of Rectangular Solid :"; cin>>height; volume=length*width*height; cout<<"volume of Rectangular Solid = :"<<volume<<" units."<<endl; return 0; }
Output:
Enter length of Rectangular Solid :1 Enter width of Rectangular Solid :2 Enter length of Rectangular Solid :3 Volume of Rectangular Solid = :6 sq. units.
/* to calculate the surface of the Rectangular Solid. */ #include <iostream> using namespace std; int main() { double length,width,height,surface; cout<<"Enter length of Rectangular Solid :"; cin>>length; cout<<"Enter width of Rectangular Solid :"; cin>>width; cout<<"Enter length of Rectangular Solid :"; cin>>height; surface=2*length*width+2*width*height+2*length*height; cout<<"surface of Rectangular Solid = :"<<surface<<" sq. units."<<endl; return 0; }
Output:
Enter length of Rectangular Solid :2 Enter width of Rectangular Solid :3 Enter length of Rectangular Solid :4 surface of Rectangular Solid = :52 sq. units.