Advertisements
Advertisements
Question
Write an OOP in C++ to find area of triangle.
(hint = a = 1/2 * b * h)
Code Writing
Advertisements
Solution
#include <iostream.h>
class triangle
{
private :
float a;
float b;
float h;
Public :
void area (void);
};
void triangle : : areaO
{
count<<<"Enter Base and height",
cin>>b>>sh;
a = 0.5 * b * h;
count <<"\n Area of triange" <<a;
}
mainO
{
triangle t;
t. area()_;
return)o);
}shaalaa.com
Is there an error in this question or solution?
