Create C++ full program that calculates area of a rectangle and triangle
#include <iostream>
using namespace std;
int main()
{
int length,width, height,base,area;
cout << "Enter the width" << endl;
cin>>width;
cout << "Enter the length" << endl;
cin>>length;
area=length*width;
cout<<"area of a rectagle is: "<<area<<endl;
cout << "Enter the height" << endl;
cin>>height;
cout << "Enter the base" << endl;
cin>>base;
area=0.5*base*height;
cout<<"area of a triangle is: "<<area<<endl;
return 0;
}
Comments
Leave a comment