This is code for the algebraic slope formula (y2 - y1) / (x2 - x1). I need help. My error is:
Uninitialized variable formula2 is being used without being initialized.
Can anyone help me???
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
int formula1[2];
int formula2[2];
int formula3[2];
int formula4[2];
int B, b;
int slope1((formula2[1] - formula1[1]) /(formula2[0] - formula1[0]));
int slope2((formula4[1] - formula3[1]) /(formula4[0] - formula3[0]));
cout << "Welcome to the program. ^_^" << endl;
cout << endl;
cout << "What is the X number for the first slope intercept formula? ";
cin >> formula1[0];
cout << endl;
cout << "What is the Y number for the first slope intercept formula? ";
cin >> formula1[1];
cout << endl;
cout << "What is the X number for the second slope intercept formula? ";
cin >> formula2[0];
cout << endl;
cout << "What is the Y number for the second slope intercept formula? ";
cin >> formula2[1];
cout << endl;
cout << "The slope for the first equation is: " << slope1 << "x" << endl;
cout << endl;
cout << "For the formula y = mx + b, your m is: " << slope1 << "x" << endl;
cout << endl;
cout << "What do you want b to be? ";
cin >> B;
cout << endl;
cout << "What is the X number for the first slope intercept formula? ";
cin >> formula3[0];
cout << endl;
cout << "What is the Y number for the first slope intercept formula? ";
cin >> formula3[1];
cout << endl;
cout << "What is the X number for the second slope intercept formula? ";
cin >> formula4[0];
cout << endl;
cout << "What is the Y number for the second slope intercept formula? ";
cin >> formula4[1];
cout << endl;
cout << "The slope intercept for the second equation is: " << slope2 << "x" << endl;
cout << endl;
cout << "For the formula y = mx + b, your m is: " << slope2 << "x" << endl;
cout << endl;
cout << "What do you want b to be? ";
cin >> b;
cout << endl;
if (slope1 == slope2 && B == b)
{
cout << "The Lines are the same line. " << endl;
cout << endl;
}
else if (slope1 == slope2 && B != b)
{
cout << "The lines are parallel." << endl;
cout << endl;
}
else if (slope1 != slope2 && B == b)
{
cout << "The lines intersect at B." << endl;
cout << endl;
}
else if(slope1 != slope2 && B != b)
{
cout << "The lines intersect." << endl;
cout << endl;
}
system("pause");
return 0;
}