
Elaboreaza un program in Turbo PAscal care sa calculeze aria si perimetrul unui triunghi


Ответы на вопрос

Turbo Pascal разрабатывает программу для вычисления площади и периметра треугольника



Sure, here's a program in Turbo Pascal that calculates the area and perimeter of a triangle:
scssprogram TriangleAreaPerimeter;
var
side1, side2, side3, perimeter, area, s: real;
begin
writeln('Enter the length of side 1: ');
readln(side1);
writeln('Enter the length of side 2: ');
readln(side2);
writeln('Enter the length of side 3: ');
readln(side3);
perimeter := side1 + side2 + side3;
s := perimeter / 2;
area := sqrt(s * (s - side1) * (s - side2) * (s - side3));
writeln('Perimeter of the triangle is: ', perimeter:0:2);
writeln('Area of the triangle is: ', area:0:2);
readln;
end.
In this program, we first ask the user to enter the lengths of the three sides of the triangle. Then, we calculate the perimeter using the formula perimeter = side1 + side2 + side3
. We also calculate the semi-perimeter, s = perimeter / 2
, which is used in the formula for calculating the area of the triangle. Finally, we calculate the area of the triangle using the formula area = sqrt(s * (s - side1) * (s - side2) * (s - side3))
.
We then display the values of the perimeter and area to the user using the writeln
function. The :0:2
syntax is used to format the output to display two decimal places.
I hope this helps!


Топ вопросов за вчера в категории Информатика







Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili