Code:
float slope(float x);
using namespace std;
//Lownum is also X Value
void main()
{ float upnum, lownum, inc, y, a;
cout << "Slope Function Program" << endl << endl;
cout << "Enter Lower Limit: ";
cin >> lownum;
cout << "Enter Upper Limit: ";
cin >> upnum;
cout << "Enter Increment: ";
cin >> inc;
cout << endl;
cout << left << setw(8) << "X Value" << " " << left << setw(8) << "Y Value" << endl;
cout << "--------" << " " << "--------" << endl;
a = slope(lownum);
}
float slope(float x)
{ float upnum, x, inc, y, lownum;
while(x<=upnum)
{
if(x<0)
{
y = x * (-1);
}
else if(x>2)
{
y = 4;
}
else if(x>=0 && x<=2)
{
y = x * x;
}
cout << fixed << setprecision(2);
cout << right << setw(8) << lownum << " " << right << setw(8) << y << endl;
lownum = lownum + inc;
}
}
theres my updated code. Ok this is really ........in me off. ITs taking me like 3 hours. I can write the program fine, i just dont understand the use of a function,why its there, its naming scheme, and what name goes with what name. Like does the name inside of slope() have any relation at all? I'm just all around confused.