Cnvmendoza

Width_Rectangle

Oct 20th, 2021 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. int main(){
  6.     // Variables
  7.     float length;
  8.     float width;
  9.     float X_AREA;
  10.     // Inputs
  11.     cout << "Area of the Rectangle: ";
  12.     cin >> X_AREA;
  13.     // X_AREA = ((4 * width) + 4) * (width - 1)
  14.     // A = 4w^2 - 4w + 4w - 4
  15.     // A = 4w^2 - 4
  16.     // sqrt((A + 4)/4) = sqrt(w^2)
  17.     // w = sqrt((A + 4/4)
  18.     // Find the width and length
  19.    
  20.     //X_AREA = (4 * pow(width,2) - 4);
  21.     width = sqrt((X_AREA + 4)/4);
  22.     length = 4 * width;
  23.     cout << "Length of the Rectangle: " << length << endl;
  24.     cout << "Width of the Rectangle: " << width;
  25. }
Add Comment
Please, Sign In to add comment