Simple probblem.. expected primary expression before

So i'm writing a program that will calculate slope with a function called linear, a loop is required in main to execute this. Also a requirement that if the two x coordinates are the same(using two points on a line) that it prints out this is a vertical line and the equation is " ". I'm having trouble with the if statement if (cord1!==x) giving me the error [Error] expected primary-expression before '=' token


Any input will be much appreciated! The code is halfway done by the way, also required to get the intercept of the line. Just struggling with this part specifcally.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  #include <iostream>
#include <cmath>

using namespace std;

void linear (double ,double,double,double,double&,double&);

int main()
{
	double x,y,cord1,cord2,slope,intercept;
	
	
	
	do {
	
	
	cout<<"Enter two points for a line:\n";
	cin>>x>>y;
	cout<<"Enter two points for the same line:\n";
	cin>>cord1,cord2;
	
}
	while(x==cord1);
	
				cout<<"This is a vertical line,";
				cout<<"The equation is:"<<x<<"="<<cord1;
					
					
			if (cord1!==x)
			
				linear(x,y,cord1,cord2,slope,intercept);
			
		
	
	
	cout<<"The slope of your coordinates are: "<<slope;
	
	return 0;

	
}


void linear (double n1, double n2,double n3, double n4,double&slopes,double&inter)
{
	slopes= (n4-n2)/(n3-n1);
	inter=(n2=(slopes)(n3))
	
	
	
}
That's probably because there is no operator!==, you probably want operator!=.


Bahaha, good lord. Thank you for pointing that out. Everything else is running smooth but one more thing, the only thing I changed was that operator. I now get the error on line 47 which I changed to
inter=(n2-(slopes)(n3))

The error I get is that slopes cannot be used as a function. Forgive the simple questions.. still trying to get c++ down.
Last edited on
You forgot the * between slopes and n3.
Ahh, thank you for pointing that out that was the problem lol. For some reason I was thinking it would do the operations like my TI 84
Topic archived. No new replies allowed.