test3.cpp:6: error: expected primary-expression before ‘int’

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double a,b,c;
	double x1,x2;
	a=2.0;
	b=5.0;
	c=3.0;
	x1=(-b+sqrt(b*b-4.0*a*c))/(2.0*a);
	x2=(-b-sqrt(b*b-4.0*a*c))/(2.0*a);
	cout<<"x1 = "<<x1<<endl;
	cout<<"x2 = "<<x2<<endl;
	return 0;

}


Compiler gives an error telling " test3.cpp:6: error: expected primary-expression before ‘int’ ". Can someone please tell me whats wrong.
closed account (jLNv0pDG)
Works fine for me.

What compiler are you using?
If you're using VC++ do you have other .cpp files in the solution you forgot to remove?

1
2
3
int main()
x1 = -1

x2 = -1.5
Last edited on
Topic archived. No new replies allowed.