Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

what am i doing wrong compiler gives this error warning C4101: \'slopeintercept\

ID: 3640337 • Letter: W

Question

what am i doing wrong
compiler gives this error
warning C4101: 'slopeintercept' : unreferenced local variable
warning C4700: uninitialized local variable 'slope' used
warning C4700: uninitialized local variable 'x1' used
warning C4700: uninitialized local variable 'x2' used
warning C4700: uninitialized local variable 'y2' used
warning C4700: uninitialized local variable 'y1' used

code i wrote
double slopeIntcptFromPt(double& slopeintercept)
{


bool slope;
int x1,y1,y2,x2;
double m,b;
while (slope==true)
{
if (x1>x2 || x2>x1)
slope=true;
else
slope=false;
cout<<"the slope is undefined"<<endl;
}

m=(y2-y1)/(x2-x1);
b=(m*x1)+y1;

return slopeintercept;

Explanation / Answer

assign your x1 y1 x2 y2 to the variable in your slopeintercept data structure

it can be done in the following way .im assuming ur variables defined in slope intercept data structure are" double x1 y1 x2 y2"
double slopeIntcptFromPt(double& slopeintercept)
{


bool slope;
double x1,y1,y2,x2;
x1=slopeintercept-->x1;
y1=slopeintercept-->y1;
x2=slopeintercept-->x2;
y2=slopeintercept-->y2;
double m,b;
if((x1-x2)==0)
{
cout<<"the slope is undefined"<<endl;
}

m=(y2-y1)/(x2-x1);
b=(m*x1)+y1;

return slopeintercept;
}