### Graph on Console

Thanks.
Last edited on
I think I would have three functions here:
 ``123456789101112`` ``````// Converts degrees to radians double radians(int degrees); // Maps a value to a range // For changing your results of -1 - 1 to 0 - 80 (the console width) // (Figuring out the position of the *) // Called like: int result = map(0 , 80,-1.0, 1.0, sin( radians(60) )); int map(int viewLow, int viewHigh, double dataMin, double dataMax, double data); // Print a line // given the position of the astericks, print the line with a '|' in the middle void printLine(int astericksPos, int linePos = 40);``````

Main would be:
 ``1234567891011`` ``````int main(void) { for (int i = 0; i < 360; i++) { double rads = radians(i); double value = sin(rads); int mapped = map(0, 80, -1.0, 1.0, value); printline(mapped); } return 0; }``````

Last edited on
Thanks.
Last edited on
Do a google search of modular programming. I'm not too familiar with the term, so I figure it has to do with OOP.

Function example:
 ``1234567891011121314151617`` ``````#include using namespace std; //Function declaration void hello(); int main(void) { hello(); return 0; } // Function definition void hello() { cout << "Hello World\n"; }``````

The function declaration only states that there is something called "hello", and that it takes no arguments. The Definition is where the actual code of the function goes.