I wrote the following code based on y=ax+b. It will ask a user to input 2 values (a and b), and show them the values of (x,y). Also, the user is asked to input a char marker, in which the line of the graph will be drawn. Problem is, I don't know how to draw a graph (with x and y axis), and then to plot the values. Here is what I have so far:
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
{
double slope, intercept, y;
char graph_char;
cout << "Enter a and b from the equation y = ax + b:\n";
cout << "a: ";
cin >> slope;
cout << "b: ";
cin >> intercept;
cout << "\nY: ";
for (int x=0;x<21;x++)
{
y = (slope * x) + intercept;
cout << "(" << x << "," << y << ") ";
}
cout<< "\nEnter the character marker for the graph: ";
cin>> graph_char;
}
return 0;
}
Thanks for any advice....
#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
{
double slope, intercept, y;
char graph_char;
cout << "Enter a and b from the equation y = ax + b:\n";
cout << "a: ";
cin >> slope;
cout << "b: ";
cin >> intercept;
cout << "\nY: ";
for (int x=0;x<21;x++)
{
y = (slope * x) + intercept;
cout << "(" << x << "," << y << ") ";
}
cout<< "\nEnter the character marker for the graph: ";
cin>> graph_char;
}
return 0;
}
Thanks for any advice....
