On Saturday, 20 February 2016 at 01:48:35 UTC, Ali Çehreli wrote:
On 02/19/2016 03:56 PM, Lisa wrote:
Can you please help me and explain how to create a program,
which would
find area of triangle and its perimeter?
It's great to have student questions on this forum. If you
don't mind telling us, which teacher and school teaches or uses
D? The only one that I know of is Professor Chuck Allison at
Utah Valley University.
Assuming that you are given the lengths of the three sides, you
can calculate the area with Heron's formula. I had used that
method in this otherwise unrelated chapter:
http://ddili.org/ders/d.en/invariant.html
Ali
import std.stdio;
import std.math;
int main()
{
double a, b, c, p;
writef("Enter a: ");
scanf("%d", &a);
writef("Enter b: ");
scanf("%d", &b);
writef("Enter c: ");
scanf("%d", &c);
p = a + b + c;
writeln("P=", p);
return 0;
}
I try to do just perimetr, but it doesn't work :(