CSCI 201 Lab 7 -- Loops in C++

Getting ready

If a directory called C:\files\Lab7 presently exists on your computer, delete it.

Download a ZIP'ed copy of the Lab 7 projects and store it in the C:\files directory. Use PowerZip to extract the files to the c:\files directory. This should create two new directories: Lab7 and Lab7\TurnOn.

Loops

Open, build, and run the workspace c:\files\Lab7\TurnOn\TurnOn.dsw. Take a look at Funky.cpp; you have to rewrite these functions. This time you have to call a function TurnOn with a integer which gives the number of a square to paint red. The table below tells you exactly which squares to turn on in each function.

Your task and your instructor's checkoff

You are to write five functions that do the following:
0 Turn on every third integer from 0 to 99.
1 Turn on all squares (0, 1, 4, 9, ...) from 0 to 99.
2 Turn on all powers of two (1, 2, 4, 8, ...) from 0 to 99.
3 Turn on the first fifteen numbers that are divisible by either three or seven.
4 Turns on every number from 0 to 99 which divides into 8,393,022 without leaving a remainder, that is, 8393022 % i is zero.

Return to CSCI 201 page
CSCI logo Return to the UNCA Computer Science home page