help fixing small error!
I'm supposed to find the equation of a line and the slope but I keep getting an error on line 17 that says
error: expected ';' before '{' 
. Don't know how to fix it. Please help, thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

#include <iostream>
using namespace std;
int main () {
double x1, y1, x2, y2, m, b;
cout << " Enter X1: " << endl;
cin >> x1;
cout << " Enter Y1: " << endl;
cin >> y1;
cout << " Enter X2: " << endl;
cin >> x2;
cout << " Enter Y2: " << endl;
cin >> y2;
if (x1 == x2) {
cout << " The slope is undefined." << endl;
}
else m = (y2y1)/(x2x1) {
cout << " The slope is: " << m << endl;
b = y1(m*x1)
cout << " The yintercept is: " << b << endl;
}
return 0;
}
 
1 2 3 4 5 6 7 8

else m = (y2y1)/(x2x1) {
cout << " The slope is: " << m << endl;
b = y1(m*x1)
cout << " The yintercept is: " << b << endl;
}
return 0;
}
 
should look like
1 2 3 4 5 6 7 8 9

else {
m = (y2y1)/(x2x1);
cout << " The slope is: " << m << endl;
b = y1(m*x1);
cout << " The yintercept is: " << b << endl;
}
return 0;
}
 
There was a semi colon missing at the end of line 19 as well.
1 2 3 4 5 6

else if ( m = (y2y1)/(x2x1) )
{
cout << " The slope is: " << m << endl;
b = y1(m*x1);
cout << " The yintercept is: " << b << endl;
}
 
Is this what you wanted?
missing semicolon
line 17 else m = (y2y1)/(x2x1);
line 19 b = y1(m*x1);
Topic archived. No new replies allowed.