Написать программу в СИ++
Радиус круга задать в главной функции. По желанию пользователя в отдельной функции вычислить, либо площадь круга, либо длину окружности. Результат вывести в главной функции

21 Июн 2019 в 19:41
243 +2
0
Ответы
1
include include

using namespace std;

double calculateArea(double radius) {
return M_PI * pow(radius, 2);
}

double calculatePerimeter(double radius) {
return 2 M_PI radius;
}

int main() {
double radius;
char choice;

cout << "Enter the radius of the circle: ";
cin >> radius;
cout << "Do you want to calculate the area (a) or the perimeter (p) of the circle? ";
cin >> choice;
if (choice == 'a') {
cout << "The area of the circle is: " << calculateArea(radius) << endl;
} else if (choice == 'p') {
cout << "The perimeter of the circle is: " << calculatePerimeter(radius) << endl;
} else {
cout << "Invalid choice. Please enter 'a' for area or 'p' for perimeter." << endl;
}
return 0;

}

21 Апр 2024 в 00:50
Не можешь разобраться в этой теме?
Обратись за помощью к экспертам
Гарантированные бесплатные доработки в течение 1 года
Быстрое выполнение от 2 часов
Проверка работы на плагиат
Поможем написать учебную работу
Прямой эфир