# [newbie question] need help programming in c++

Discussion in 'Computer Support' started by Phate, Oct 1, 2003.

1. ### PhateGuest

hi, i am trying to find the perimeter and area of a quadrilateral but
something is seriously wrong with the area portion of my code, this is my
program so far:

#include <iostream.h>
#include <math.h>

int main()
{
double x1, x2, x3, x4, y1, y2, y3, y4, d1, d2, d3, d4, td, s, a, h, b;

cout<<"This program will find the perimeter and area of a
cin>>x1;
cin>>y1;
cin>>x2;
cin>>y2;
cin>>x3;
cin>>y3;
cin>>x4;
cin>>y4;
d1=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
d2=sqrt(((x2-x3)*(x2-x3))+((y2-y3)*(y2-y3)));
d3=sqrt(((x3-x4)*(x3-x4))+((y3-y4)*(y3-y4)));
d4=sqrt(((x4-x1)*(x4-x1))+((y4-y1)*(y4-y1)));
td=d1+d2+d3+d4;
b=sqrt(((x1-x3)*(x1-x3))+((y1-y3)*(y1-y3)));
s=(d1+d2+b)/2;
h=sqrt((s)*(s-d1)*(s-d2)*(s-b)); //heron
formula
a=((.5)*b*h)/10;
return 0;
}

Phate, Oct 1, 2003

2. ### why?Guest

These are questions for you to work on by yourself, if you want to reply
fine.

So your input is? Which gives what answer? If you do the calculation by
hand following the method below you get what?

Use cout to display intermediate results, do they match the traditional
manual calculation at each step?

.... education now days... sheesh....
<snip>

Me

why?, Oct 1, 2003

3. ### yellow submarineGuest

We all know that Phate screamed at the top of his lungs:
|---------|
a | |
|--------- |
B
--

Do the Dew - Dewman
has been changed to
We all Live in a "Yellow Submarine"

DUH

yellow submarine, Oct 1, 2003
4. ### °Mike°Guest

°Mike°, Oct 1, 2003