--- In [email protected], "Paul Herring" <[EMAIL PROTECTED]> wrote: > > On Feb 8, 2008 11:23 AM, umar hayat <[EMAIL PROTECTED]> wrote: > > ----- Original Message ---- > > I AM UMAR from islamabad > > -------------------------------------------------------- > > #include<iostream.h> > > Deprecated header. > > > void main() > > main returns int, not void, float or struct foo. > > > { > > int x1,x2,x3,y1,y2,y3; > > All these variables are uninitialised. > > > int p1=(x1+x2+x3)/2; > > int p2=(y1+y2+y3)/2; > > Initialised using uninitialised variables - the answers will be > nonsense. This also appears to assume the centroid is a triangle. > > > cout<<" x component of centroid="<<p1<<endl; > > cout<<" y component of centroid="<<p2<<endl; > > No newlines, so this program needn't output anything at all. > > > } > > ------------------------------------------------- > > -- > PJH > > http://shabbleland.myminicity.com/ind >
UMAR Hi, Another problem is the type of p1 and p2. The type should be float or likewise. Using here 'int' as a type inherently adds a quantization error. Moshe
