Comment this code line by line in simple english
AC=(pow((float)(Point2DA[0]-Point2DC[0]),2)+pow((float)(Point2DA[1]-Point2DC[1]),2));
AB=(pow((float)(Point2DA[0]-Point2DB[0]),2)+pow((float)(Point2DA[1]-Point2DB[1]),2));
BC=(pow((float)(Point2DB[0]-Point2DC[0]),2)+pow((float)(Point2DB[1]-Point2DC[1]),2));
}
float Area(){
return abs((Point2DA[0]*(Point2DB[1]-Point2DC[1])+Point2DB[0]*(Point2DC[1]-Point2DA[1])+Point2DC[0]*(Point2DA[1]-Point2DB[1]))/2.0);
}
bool IsRightAngleTriangle(){
return (((AC == (AB + BC)) || (AB == (AC + BC) ) || (BC == (AC + AB))));
}
void Output(){
cout << "The area of triangle: " << Area() << "\n";
if(IsRightAngleTriangle()){
cout << "It is a right angle triangle\n";
cout << "The length of Base: " << Base() << "\n";
cout << "The length of Perpendicular: " << Perpendicular() << "\n";
AC=(pow((float)(Point2DA[0]-Point2DC[0]),2)+pow((float)(Point2DA[1]-Point2DC[1]),2));// calculating the value of AC using pow function
AB=(pow((float)(Point2DA[0]-Point2DB[0]),2)+pow((float)(Point2DA[1]-Point2DB[1]),2));// calculating the value of AB using pow function
BC=(pow((float)(Point2DB[0]-Point2DC[0]),2)+pow((float)(Point2DB[1]-Point2DC[1]),2)); // calculating the value of BC using pow function
}
float Area(){ //function definition of area function for area calculation
return abs((Point2DA[0]*(Point2DB[1]-Point2DC[1])+Point2DB[0]*(Point2DC[1]-Point2DA[1])+Point2DC[0]*(Point2DA[1]-Point2DB[1]))/2.0);
}
bool IsRightAngleTriangle(){ //function to check whether it is right angled triangle
return (((AC == (AB + BC)) || (AB == (AC + BC) ) || (BC == (AC + AB)))); //condition checking
}
void Output(){ //function to give area as output
cout << "The area of triangle: " << Area() << "\n";// giving area as output
if(IsRightAngleTriangle()){// condition checking using if statement
cout << "It is a right angle triangle\n";
cout << "The length of Base: " << Base() << "\n";//printing base
cout << "The length of Perpendicular: " << Perpendicular() << "\n"; //printing perpendicular
Comments
Leave a comment