Given circumference of the circle, find the area of the square that has the same perimeter as the circle


SUBMITTED BY: Guest

DATE: Oct. 12, 2013, 3:10 p.m.

FORMAT: C++

SIZE: 821 Bytes

HITS: 1451

  1. #include <stdio.h>
  2. int main()
  3. {
  4. const float PI = 3.1415;
  5. float circumference;
  6. float radius_of_circle;
  7. float area_of_circle;
  8. float side_of_square;
  9. float perimeter_of_square;
  10. float area_of_square;
  11. printf("\n Please enter the circumference of the circle : ");
  12. scanf_s("%f", &circumference);
  13. radius_of_circle = circumference / (2 * PI);
  14. area_of_circle = PI * radius_of_circle * radius_of_circle;
  15. perimeter_of_square = circumference;
  16. side_of_square = perimeter_of_square / 4;
  17. area_of_square = side_of_square * side_of_square;
  18. printf("\n The area of the circle is %f", area_of_circle);
  19. printf("\n The area of the square is %f", area_of_square);
  20. getchar();
  21. getchar();
  22. return 0;
  23. }

comments powered by Disqus