okay what's wrong with this program ? it shows me delta but not more ..i want to see x1,x2 too ..
#include <iostream>
#include <stdio.h>;
#include <math.h>;
void main()
{
int a,b,c;
float x1,x2,delta,d;
cout<<"Scrieti a = ";
cin>>a;
cout<<"Scrieti b = ";
cin>>b;
cout<<"Scrieti c = ";
cin>>c;
if (a==0)
g<<"Ecuatie de gradul I";
else
{
delta = pow(b,2)-4*a*c;
if (delta>0)
{
x1 = (-b+sqrt(delta))/(2*a);
x2 = (-b-sqrt(delta))/(2*a);
cout<<"x1 = "<<x1<<" x2 = "<<x2;
}
else
if (delta==0)
{
g<<"ecuatia are doar o solutie";
g<<"x1=x2="<<-b/(2*a);
}
else
g<<"ecuatia nu are solutii vezi doamne in multimea numerelor reale"
}
f.close();
g.close();
}
there are some romanian words in there but i dont think it will cause any problem :)
this is the first exercise i ever done in c ++ ...and it seems like i`m kinda pathetic :)
i would appreciate a working program for quadratic equation tho :)
How does it show you delta? I don't see an output statement for delta.
What are f and g? You close them at the end of the program as if they were streams, but you haven't defined them earlier in the program as streams and opened them.
You have defined the variable d, but never use it.
I don't think you have a closing brace for the end of the main routine.