Why is this so? Where there is a mistake?
#include
#include
#include
using namespace std;
Int main ()
{
Float xa, ya, xb, yb, xc, yc, a, b, c, p, s;
cin> Xa & gt;> Ya & gt;> Xb & gt;> Yb & gt;> Xc & gt;> Yc.
A=SQRT ((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
B=SQRT ((xc - xb) * (xc - xb) + (yc - yb) * (yc - yb));
C=SQRT ((xc - xa) * (xc - xa) + (yc - ya) * (yc - ya));
P=(a + b + c)/2;
S=SQRT (p * (p - a) * (p - b) * (p - c));
Cout & lt; & lt; Fixed & lt; & lt; Setprecision (2);
Cout & lt; & lt; s;
}
CodePudding user response:
Using a double instead of floatCodePudding user response:
Will float (single) replaced by double (double fine)# include & lt; Iostream>
#include
#include
using namespace std;
Int main ()
{
Double xa, ya, xb, yb, xc, yc, a, b, c, p, s;
cin> Xa & gt;> Ya & gt;> Xb & gt;> Yb & gt;> Xc & gt;> Yc.
A=SQRT ((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
B=SQRT ((xc - xb) * (xc - xb) + (yc - yb) * (yc - yb));
C=SQRT ((xc - xa) * (xc - xa) + (yc - ya) * (yc - ya));
P=(a + b + c)/2;
S=SQRT (p * (p - a) * (p - b) * (p - c));
Cout & lt; & lt; Fixed & lt; & lt; Setprecision (2);
Cout & lt; & lt; s;
}