Answer to Question #184072 in C++ for Bilal

Question #184072

Comment this code line by line in simple english

int CD=(pow((float)(points2D[4]-points2D[6]),2)+pow((float)(points2D[5]-points2D[7]),2));
 
        int ACDiagonal=(pow((float)(points2D[0]-points2D[4]),2)+pow((float)(points2D[1]-points2D[5]),2));
 
        return ( ACDiagonal == (AB + BC)) && (ACDiagonal == (AD + CD));
 
    }
 
 
    void Output(){
 
        if(IsRectangle()){
 
            cout<<"\nIt is a rectangle.\n";
 
            cout<<"Area: "<<Area()<<"\n";
 
            cout<<"Length: "<<Length()<<"\n";
 
            cout<<"Height: "<<Height()<<"\n";
 
            cout<<"Perimeter: "<<Perimeter()<<"\n";
 
            cout<<"Diagonal: "<<Diagonal()<<"\n";
 
        }else{
 
            cout<<"\nIt is not a rectangle.\n";
 
        }
 
    }
 
 
    float Length(){
 
        return sqrt(pow((float)(points2D[4]-points2D[2]),2)+pow((float)(points2D[5]-points2D[3]),2));
 
    }
 
1
Expert's answer
2021-04-25T11:32:24-0400
int CD=(pow((float)(points2D[4]-points2D[6]),2)+pow((float)(points2D[5]-points2D[7]),2)); // defining and initializing CD with value: ((4th is element of array points2D - 6th element of array points2D) in 2d power) + ((5th element of array points2D - 7th element of array points2D) in 2d power)
 
    int ACDiagonal=(pow((float)(points2D[0]-points2D[4]),2)+pow((float)(points2D[1]-points2D[5]),2)); // defining and initializing ACDiagonal with value: ((0th element of array points2D - 4th element of array points2D) in 2d power) + (1st element of array points2D - 5th element of array points2D) in 2d power)
 
    return ( ACDiagonal == (AB + BC)) && (ACDiagonal == (AD + CD));
 
  }  // returning true if both statements: 1)ACDiagonal equal to AB + BC and 2)ACDiagonal equal to AD + CD, false if one of those statements is false
 
 
  void Output(){  // function definition
 
    if(IsRectangle()){  // if function IsRectangle() is returning true
 
      cout<<"\nIt is a rectangle.\n"; // print on console from the new string message “It is a rectangle, and again start from new string(\n)
 
      cout<<"Area: "<<Area()<<"\n";  // print on console message “Area: “ and calling function Area(), start from new string
 
      cout<<"Length: "<<Length()<<"\n";  // print on console message “Length: “ and calling function Length() and start from new string
 
      cout<<"Height: "<<Height()<<"\n"; // print on console message “Height: “ and calling function Height() and start from new string
 
      cout<<"Perimeter: "<<Perimeter()<<"\n"; // print on console message “Perimeter: “ and calling function Perimeter() and start from new string
 
      cout<<"Diagonal: "<<Diagonal()<<"\n"; // print on console message “Diagonal: “ and calling function Diagonal() and start from new string
 
    }else{ // if if statement return false it will act this block
 
      cout<<"\nIt is not a rectangle.\n"; // from the new string print to the console “It is not rectangle.” , go to new string
 
    }
 
  }
 
 
  float Length(){  // function Length() definition
 
    return sqrt(pow((float)(points2D[4]-points2D[2]),2)+pow((float)(points2D[5]-points2D[3]),2)); // returning value: (4th element of array points2D - 2d element of array points2D) in 2d power) + (5th element of array points2D - 3d element of array points2D) in 2d power)
  }

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS