From 7e3078bdf288a26331d96c2bac4343eedecf2f7f Mon Sep 17 00:00:00 2001 From: lupanova Date: Sat, 16 Nov 2019 15:52:55 +0300 Subject: [PATCH] first attempt --- include/task1.h | 6 ++++++ src/main1.cpp | 29 +++++++++++++++++++++++++++++ src/task1.cpp | 8 ++++++++ 3 files changed, 43 insertions(+) create mode 100644 include/task1.h create mode 100644 src/main1.cpp create mode 100644 src/task1.cpp diff --git a/include/task1.h b/include/task1.h new file mode 100644 index 0000000..14c55a7 --- /dev/null +++ b/include/task1.h @@ -0,0 +1,6 @@ +#ifndef TEST01_H +#define TEST01_H + +double CalculateSphereVolume(double radius); + +#endif \ No newline at end of file diff --git a/src/main1.cpp b/src/main1.cpp new file mode 100644 index 0000000..7fe9302 --- /dev/null +++ b/src/main1.cpp @@ -0,0 +1,29 @@ +#include "test01.h" +#define _CRT_SECURE_NO_WARNINGS +#include + +#define TASK_2 + +#ifdef TASK_1 +int main() +{ + double radius = 0; + puts("Enter a radius:"); + scanf_s("%lf", &radius); + printf("Volume of sphere is %.2lf\n", + CalculateSphereVolume(radius)); + return 0; +} +#endif + +#ifdef TASK_2 +int main() +{ + double radius = 0; + puts("Enter a radius:"); + scanf_s("%lf", &radius); + printf("Area of circle %.2lf\n", + 3.14*radius*radius); + return 0; +} +#endif \ No newline at end of file diff --git a/src/task1.cpp b/src/task1.cpp new file mode 100644 index 0000000..12f223f --- /dev/null +++ b/src/task1.cpp @@ -0,0 +1,8 @@ +#include "test01.h" +#define _USE_MATH_DEFINES +#include + +double CalculateSphereVolume(double radius) +{ + return (double) 4 / 3 * M_PI * pow(radius, 3); +} \ No newline at end of file