anyway at the end of program, i try to add the system("pause"); and the return 0;
but when i try to compile with them it doesnt work >.<
P.S.: it works without them but i cant see the result.
Are you sure you added the #include <limits> at the top of your file, and the cout and cin.ignore calls at the end of your int main()-function?
Also, 0-b can be written as -b (since - is a unary operator, too). A smart compiler should pick this out, but it's a bad practice, typing things you don't need.
#include<iostream>
#include<cmath>
usingnamespace std;
int main()
{
double a,b,c,delta,x1,x2,x;
cout<<"Ecuatia de gradul 2.\n";
cout<<"Introduceti a=";
cin>>a;
cout<<"Introduceti b=";
cin>>b;
cout<<"Introduceti c=";
cin>>c;
if (a!=0)
{
delta=b*b-4*a*c;
cout<<"delta="<<delta<<endl;
if (delta<0)
{
cout<<"x nu apartine R, x apartine C."<<endl;
}
elseif (delta==0)
{
x1=x2=-b/a;
cout<<"x1=x2="<<x1<<endl;
}
else
{
x1=(0-b-sqrt(delta))/2*a;
cout<<"x1="<<x1<<endl;
x2=(0-b+sqrt(delta))/2*a;
cout<<"x2"<<x2<<endl;
}
}
elseif (b!=0)
{
x=-c/b;
cout<<"x="<<x<<endl;
}
elseif (c==0) cout<<"Ecuatie nedeterminata\n";
else cout<<"Ecuatie imposibila\n";
}
system("pause");
return 0;
and the error sais:
1 2 3 4
row 43: expected constructor, destructor, or type conversion before '(' token
row 43: expected `,' or `;' before '(' token
row 44: expected unqualified-id before "return"
row 45: expected declaration before '}' token
Because you did not end the main() function call, add a } to the end of your program. (Because of this, your program will not recognize the main function, and will state that return is unexpected and what not.
What Galik said. (Didn't notice the } above the system call, try indenting your code better).