We're going to give you two projects to start the lab.
Download a
ZIP'ed copy of the
Lab 7 projects and store it in the
`C:\FILES` directory.

Go into the `MS-DOS` prompt and execute the
following commands:

`cd c:\files``mkdir Lab07``cd Lab07``pkunzip -d ..\lab07.zip`

`Ezwinvc50.lib`-- the EzWindows library`Main2D.cpp`-- a*driver*program`Funky.cpp`-- the file you'll change

The driver program `Main2D.cpp`
uses the EzWindows library to sequentially plot five functions that you will
write. Use the
mouse to move between functions. Press the `X` in the
upper right
corner of the window to terminate the program.

You should *not* modify `Main2D.cpp` in this
lab. However, you are encouraged to look at it to learn
a bit more about C++ and EzWindows.

The program you will modify is called
`Funky.cpp`.
Presently, this program contains five simple functions similar to:

float MyFuncN(const float x) { return N*x ; }

Go ahead and build and execute this project and look at its boring functions.

- 0.7 sine(6
`x`) + 0.2 sine(20`x`) - absolute value of
`x`, that is,

-`x`, if`x`is negative,

and`x`, if`x`is positive

`x`* sine(1/`x`), if`x`is not zero,

0, if`x`is zero- sqrt(1 -
`x`^{2}) - First, set a
`float`variable`z`to`x`.

Go into a`for`-loop, and execute

10 times.`z`=`z`*`z`

In a second`for`-loop, execute

10 times.`z`= sqrt(`z`)

Return`z`as the result of your function.

`Ezwinvc50.lib`-- the EzWindows library`Main3D.cpp`-- a*driver*program`Funky.cpp`-- the file you'll change

The driver program `Main3D.cpp`
will call the function *you will write*.
It will pass two `float` arguments.
Your function will return a `float` which will be used in the plot.
Since we don't have 3-D holographic displays, we have to plot
your function on a two dimensional screen. This is done by using
the number returned by your function to choose between six different
colors. The succinct explanation is that everything before
the decimal point in your floating point number is discarded,
and the fractional part is used to select a color from the
following table:

Range | Color |
---|---|

.00 to .1666.. | Red |

.1666.. to .3333.. | Yellow |

.3333.. to .50 | Green |

.50 to .6666.. | Cyan |

.6666.. to .8333.. | Blue |

.8333.. to .00 | Magenta |

Go ahead and build and run the program.
Then look at `Main3D.cpp` for
details of the plotting routines.

float MyFuncN(const float x, const float y) { return x+N*y ; }

Your five functions for the 3D plot are:

`x`^{2}+`y`^{2}`x`, if`x`>=`y`,

`y`, if`x`<`y`- 1/(
`x`^{2}+`y`^{2}),

Don't worry, your function will not be called when either`x`or`y`is equal to zero. - larger of the absolute values of
`x`and`y`or

MAX(|`x`|, |`y`|) - 0.5 floor(12
`x`) + 0.5 floor(12`y`)

Return to CSCI 201 page

Return to the UNCA Computer Science home page