All pastes #558047 Raw Edit

Mine

public cpp v1 · immutable
·published 2007-06-11 06:32 UTC
rendered paste body
#include <iostream>#include <math.h>using namespace std;void one(){	float a = 0.0; 	float b = 0.0; 	float c = 0.0;	float x1 = 0.0;	float x2 = 0.0;	float x3 = 0.0;	float x4 = 0.0;    		cout << "Enter the coefficients a , b , c for equation in the form ax^ + bx + c = 0:\n";	cout << "Enter value for a:\n";	cin >> a;	cout << "Enter value for b:\n";	cin >> b;	cout << "Enter value for c:\n";	cin >> c;	if(a == 0 && b == 0 && c == 0) {		x1 = 0;		x2 = 0;	cout << "The roots are:" "\n" << "x1 = " << x1 << " , " << "x2 = " << x2 << "\n";	}	if(a == 0 && b == 0 && c != 0) {	c = c;	cout << "There are no roots" "\n" << "c = " << c << "\n";	}	if(a == 0 && b != 0 && c !=0) {	cout << "The values entered do not make a quadratic expression" "\n" << "x = " << -c/b << "\n";	}	if(a == 0 && b != 0 && c == 0) {		x1 = 0;		x2 = 0;	cout << "The roots are:" "\n" << "x1 = " << x1 << " , " << "x2 = " << x2 << "\n";	}	if(a != 0 && b == 0 && c == 0) {		x1 = 0;		x2 = 0;	cout << "The values entered result in ax^= 0; so both roots are 0" "\n" << "x1 = " << x1 << " , " << "x2 = " << x2 << "\n";	}	if(a != 0 && b != 0 && c == 0) {		x1 = 0;		x2 = -b/a;	cout << "The roots are:" "\n" << "x1 = " << x1 << " , " << "x2 = " << x2 << "\n";	}	if(a < 0 && b == 0 && c < 0) {		x1 = -b/(2*a);		x4 = (b*b)-(4*a*c);		x4 = -x4;		x2 = sqrt(x4)/(2*a);		x3 = -sqrt(x4)/(2*a);	cout << "The roots are not real numbers:" "\n" << "x1 =" << x1 << " + " << x2 << " * i " << "\n" << "x2 =" << x1 << " + " << x3 << " * i " << "\n";	}	if(a > 0 && b == 0 && c > 0) {		x1 = -b/(2*a);		x4 = (b*b)-(4*a*c);		x4 = -x4;		x2 = sqrt(x4)/(2*a);		x3 = -sqrt(x4)/(2*a);	cout << "The roots are not real numbers:" "\n" << "x1 =" << x1 << " + " << x2 << " * i " << "\n" << "x2 =" << x1 << " + " << x3 << " * i " << "\n";	}	if(a > 0 && b == 0 && c < 0) {		x1 = (-b + (sqrt(pow(b,2)-(4*a*c))))/(2*a);		x2 = (-b - (sqrt(pow(b,2)-(4*a*c))))/(2*a);	cout << "The roots are:" "\n" << "x1 = "<< x1 << " , " << "x2 = "<< x2 << "\n";	}	if(a < 0 && b == 0 && c > 0) {		x1 = (-b + (sqrt(pow(b,2)-(4*a*c))))/(2*a);		x2 = (-b - (sqrt(pow(b,2)-(4*a*c))))/(2*a);	cout << "The roots are:" "\n" << "x1 = "<< x1 << " , " << "x2 = "<< x2 << "\n";	}	if(a != 0 && b != 0 && c != 0 && (4*a*c) <= pow(b,2)) {		x1 = (-b + (sqrt(pow(b,2)-(4*a*c))))/(2*a);		x2 = (-b - (sqrt(pow(b,2)-(4*a*c))))/(2*a);	cout << "The roots are:" "\n" << "x1 = "<< x1 << " , " << "x2 = " << x2 << "\n";	}	if(a != 0 && b != 0 && c != 0 && (4*a*c)> pow(b,2)) {		x1 = -b/(2*a);		x4 = (b*b)-(4*a*c);		x4 = -x4;		x2 = sqrt(x4)/(2*a);		x3 = -sqrt(x4)/(2*a);	cout << "The roots are not real numbers" "\n" << "x1 =" << x1 << " + " << x2 << " * i " << "\n" << "x2 =" << x1 << " + " << x3 << " * i " << "\n";	}return;}void two() {	char x ;        cout << "Press x and then Enter to continue...." "\n";	cin >> x;		for(;;) {			if ( x ) {				break;			}		}	cout << "Done" "\n";}int main() {one();two();return 0;}