Thread: help plz!!
View Single Post
Old 11-07-2004, 10:14 PM   #1 (permalink)
becool04
Registered User
 
Join Date: Nov 2004
Posts: 2
becool04 is on a distinguished road
Unhappy help plz!!

write a C++ program that finds the x, which is the root between -100 to 100 in linear equation y = m * x + b. The values of m and b are read of the external data file. In this program must use loops and use if statement if nessecery.
The following is the source code i wrote which doesnt work...
#include <iostream.h>
#include <fstream.h>
#include <math.h>

int main ()
{
double m = 0.0;
double b = 0.0;
double x = 0.0;
int y = 0.;

ifstream infile ( "C:/WINDOWS/Temp/output.txt");

infile >> m;
infile >> b;
cout << "m = " << m << endl;
cout << "b = " << b << endl;


for ( x = -100.; x <= 100.; x = x + 0.001)
{
y = m * x + b;
if ( y = 0)

{
cout << x <<endl;
}


}
cout << x << endl;
return 0;
}//end of main
becool04 is offline   Reply With Quote