Table of Values

  Download Source Code

/*** Table of Values *************************************
Marla is a math student.  She needs to draw graphs and analyse them.
This is easier with a table of values for the function.
The TAB character \t makes the columns line up properly.
**********************************************************/

Loops

A loop causes commands to repeat over and over again. 

   for(float x = 0; x <= 5; x = x + 0.5)
The for(...) loop causes the variable X to :

start counting at X = 0
keep counting while (as long as) X is smaller or equal to 5
add 0.5 before repeating

So X has the following values:  0 , 0.5 , 1.0 , 1.5 , 2.0 , 2.5 , ..... , 4.5 , 5.0.

At each value of X, the value of Y is calculated and then X and Y are printed.
The control character "\t" is use to create a TAB that lines up the values in two columns.
This creates a table of values as shown in the output box above.

Practice