I'm pretending to read a file and output. I have a [a11...a33] matrix and the output i'm expecting is not the one the compiler is giving me. what im i doing wrong?
This is the expected output:
a = 3, b = -2, c = -1
The value of x1 is: 1
The value of x2 is: -0.333333
1 of the x values is/are positive
This what I have worked on so far:
include <iostream>
#include <fstream>
#include <cmath>
double num_positive ( double, double);
void QuadraticEquation ( double , double , double, double&, double& );
using namespace std;
int main()
{
ifstream infile;
double y2;
double temp1=0;
double temp2=0;
double res1, res2;
double a=0 , b=0 , c=0 ;
int t1=0 , t2=0 , t3=0 ;
infile.open("data1.txt");
if (!infile)
cout << "Error: file could not be opened" << endl;
else
{
while (!infile.eof())
{
infile >> a, b, c;
infile >> a, b, c;
cout << "a = " << a << " b = " << b << " c = " << c;
}
QuadraticEquation( t1, t2,t3, res1, res2);
y2 = num_positive( temp1,temp2);
}
cout << "(The value of x1 is:)" << y2 << endl;
infile.close();
return 0;
}
void QuadraticEquation( double a , double b , double c, double &x1, double &x2 )
{
double r1, r2;
if ( ((b*B)/> - 4 * a * c )> 0 )
{
r1= (-b+sqrt((b*B)/> - 4 * a * c ))/(2*a);
r2= (-b-sqrt((b*B)/> - 4 * a * c ))/(2*a);
}
else if (((b*B)/> - 4 * a * c ) == 0)
{
r1=(-B)/>/(2*a);
r2=(-B)/>/(2*a);
}
else
cout << "The number is generated are not real." << endl;
}
double num_positive ( double q, double p )
{
double a1=0;
double b1=0;
if ( (a1 || b1) > 0 )
{
cout << "There one positive value";
}
exit (1);
}
This post has been edited by JackOfAllTrades: 03 April 2010 - 06:00 AM
Reason for edit:: Added code tags. PLEASE!!!! [code]...PUT YOUR CODE IN HERE...[/code]

New Topic/Question
Reply




MultiQuote




|