graph

Download Graph

If you can't read please download the document

Upload: cesar-jackson

Post on 20-Sep-2015

2 views

Category:

Documents


1 download

DESCRIPTION

Make a graph in C++

TRANSCRIPT

Making Text Based Graphs In CThis tutorial will show you how to make a text based graph in the C programming language. Although text based graphs have many limitations and are of no actual use, they are fun to make when learning a programming language.First of all, let us start with the headers. The math.h header is used so that we can use mathematical functions.//WinterNurf Productions#include #include #include We now start the main() function and declare two variables, i and j, to control the loop, as well as generate mathematical functions.int main(){ int i = 0, j = 0;We also declare a character and assign it the ASCII value 219. This character is a block, and we will use it as a data point for ot graph. Any other character of your choice may also be used. char a = 219;We will now create a nested loop. Our outer loop will comprise of the y - axis (note that usually the outer loop is used for rows, and so at first it may seem that rows must be used for x - axis. However, give it a thought and it becomes clear that they must be used for y - axis). We use the variable j for this. Also, we create the loop starting from 80 and ending at 1 because our console application starts printing from top left, but we want the origin of our graph to be bottom left. for (j = 80; j >= 1; j--)The inner loop will comprise of the x - axis, and is pretty straighforward. for (i = 1; i = 1; j--) for (i = 1; i