0

I am having trouble with this program in the if else part
I feel that is a really simple problem, I have tried 'else if' as well as 'else' but all sorts of errors come up.

#include <stdlib.h>
#include <iostream>
using namespace std;

int main()
{
	double a, b, c;

	cout <<"Input value for a" <<endl;
		cin >>a;
	cout <<"Input value for b" <<endl;
		cin >>b;
	cout <<"Input value for c" <<endl;
		cin >>c;

//////////////////////////////////////////////
		//LOOP
		double discriminant = ((pow(b,2))-4*a*c);
	if (a==0)
	{
			if(b==0)
				{cout <<"No solution.";}
			else 
			{cout <<"One real solution.";}
	}
	else{
		if (discriminant>0);
		{cout <<"Two real unequal solutions.";}
		else if
			{if (discriminant==0)
			{cout <<"Two real equal answers.";}
			else	
			{cout <<"Two complex conjugate solutions.";}
		}
	}
	system ("pause");
		return 0;
}
4
Contributors
3
Replies
7
Views
6 Years
Discussion Span
Last Post by Narue
0

It looks to me like you have an extra "if" and an extra pair of { } in line 30.

That is, lines 29-30 should read

else if (discriminant==0)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.