Need help

Here's the question


Write a program that allows the user to enter the slope and intercept, along with a value for n to compute the values of z for the general solution to this two variable problem. X and y vary between 1 and n.


I have no idea what to do for this program?
That's not really a question that is you stating you don't know what to do. What code have you provided so far? It seems pretty straight forward ask the user to enter the slope, intercept, and n(std::cout, std::cin). It seems that x and y also need to be between 1 and n.
"slope" and "intercept" are used usually as the names of constants in a mathematical equation: y = slope*x+intercept. That is a f(x)=y, not f(x,y)=z.

Overall, f(x)=y is not a problem. It is an equation. The analytic solution. Furthermore, printing the value of f(x) for all values of x is not a "general solution"; there are infinite number of values of x, even between 0 and 1.
Ok heres what i have so far but the last three rows are exactly the same


#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <fstream>
using namespace std;
int main ()
{
int z,slope,intercept,number,x,y;
double m,b,n;
m = slope;
b = intercept;
n = number;
cout << "enter slope" << endl;
cin >> m;
cout << "enter intercept" << endl;
cin >> b;
cout << "enter number n" << endl;
cin >> n;
if (m<0)
{
cout << "This program doesn't work for negative numbers" << endl;
}
else if (b<0)
{
cout << "This program doesn't work for negative numbers" << endl;
}
else if (n<0)
{
cout << "This program doesn't work for negative numbers" << endl;
}
else
{
cout << "Multiplication table:" << endl;
for (int x=1;x<=n;x++)
{
for (int y=1; y<=n; y++)
{
cout << m*y + b << "\t";
}
std::cout << std::endl;
}
}
system ("PAUSE");
return 0;

}
Please use code tags and sane indentation when posting code.
http://www.cplusplus.com/articles/jEywvCM9/

Of course it does. The outer loop repeats the inner loop n times and the inner loop prints every time the same n values.
Topic archived. No new replies allowed.