fork download
  1. /*******************************************************************************
  2.  * Aiden Stannard // CS1A // Chapter 4 Homework: Challange 4# // 9/26/2026
  3.  *
  4.  * Calculate Rectange Area
  5.  *
  6.  * This program receives the dimensions of two different rectangle and outputs
  7.  * which rectangle has a greater area.
  8.  *
  9.  * Inputs:
  10.  * Enter the Length and width of your first rectangle respectively
  11.  * Enter the length and width of your second rectangle respectively
  12.  *
  13.  * Output:
  14.  * The ___ rectangle has a greater area than the ____ rectangle
  15.  ******************************************************************************/
  16. #include <iostream>
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. float length;
  22. float width;
  23. float lengthTwo;
  24. float widthTwo;
  25. float area;
  26. float areaTwo;
  27.  
  28. cout << "Enter the Length and width of your first rectangle respectively" << endl;
  29. cin >> length;
  30. cin >> width;
  31. cout << "Enter the length and width of your second rectangle respectively" << endl;
  32. cin >> lengthTwo;
  33. cin >> widthTwo;
  34.  
  35. area = length * width;
  36. areaTwo = lengthTwo * widthTwo;
  37.  
  38. if (area > areaTwo)
  39. cout << "The first rectangle has a greater area than the second" << endl;
  40. else
  41. cout << "The second rectangle has a greater area than the first" << endl;
  42. return 0;
  43. }
Success #stdin #stdout 0s 5316KB
stdin
5
5
10
10
stdout
Enter the Length and width of your first rectangle respectively
Enter the length and width of your second rectangle respectively
The second rectangle has a great area than the first