Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as text by fdsaf ( 19 years ago )
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
float quadsolve ( int a, int b, int c){
float disc = pow(b,2) - (4 * a * c);
float answer[2];
int count = 0;
while ( count < 2 ) {
if (count = 0) {
answer[0] = ( (0 - b) + sqrt(disc) ) / ( 2 * a ) ;
count++;
return answer[0];
} else {
answer[1] = ( (0 - b) - sqrt(disc) ) / ( 2 * a ) ;
return answer[1];
}
}
}
int main(){
int a;
int b;
int c;
cout << "Enter your values for a, b and c respectively: ";
cin >> a >> b >> c;
cin.ignore();
cout << "The solutions are " << quadsolve(a,b,c) << " and" << quadsolve(a,b,c);
cin.get();
}
Revise this Paste