From 1748a31acd7fbdee6ca1030a68593959e25c2176 Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Tue, 3 Oct 2023 11:43:48 +0100 Subject: [PATCH] complete chapter 5 exercises --- C5/ex4.c | 11 +++++++++++ C5/ex5.c | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 C5/ex4.c create mode 100644 C5/ex5.c diff --git a/C5/ex4.c b/C5/ex4.c new file mode 100644 index 0000000..207f22b --- /dev/null +++ b/C5/ex4.c @@ -0,0 +1,11 @@ +#include +#include + +int main() { + float r; + printf("Enter radius: "); + scanf("%f", &r); + + printf("Area of circle: %f\n", M_PI*r*r); + printf("Volume of sphere: %f\n", M_PI*r*r*r*4.0/3.0); +} diff --git a/C5/ex5.c b/C5/ex5.c new file mode 100644 index 0000000..9fb188e --- /dev/null +++ b/C5/ex5.c @@ -0,0 +1,11 @@ +#include +#include + +int main() { + float r; + printf("Enter radius: "); + scanf("%f", &r); + + printf("Area of circle: %0.2f\n", M_PI*r*r); + printf("Volume of sphere: %.02f\n", M_PI*r*r*r*4.0/3.0); +}