fork download
  1. #include <stdio.h>
  2. #include <assert.h>
  3.  
  4. #define PI 3.14f
  5.  
  6. #define TRIANGLE_PERIMETER(base, height) (0.5 * (base) * (height)) // partial answer to get you started
  7. //... complete the other 5 macros as well
  8. #define RECTANGLE_PERIMETER(width, height) ((width) * (height))
  9. #define SQUARE_PERIMETER(side) ((side) * (side))
  10. #define QUADRILATERAL_PERIMETER(side1, side2, side3, side4) ((side1) + (side2) + (side3) + (side4))
  11. #define CIRCLE_PERIMETER(radius) (2 * PI * (radius))
  12. #define SECTOR_PERIMETER(radius, angle) ((radius) * (angle + 2))
  13.  
  14. int main(void) {
  15. assert (SQUARE_PERIMETER(1) == 1);
  16. assert (QUADRILATERAL_PERIMETER(1, 1, 1, 1) == 4);
  17. assert (CIRCLE_PERIMETER(100) == 628);
  18. assert (SECTOR_PERIMETER(1, 1) == 3);
  19.  
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty