Computer games were simple back in the early days. Output was printed on a teletype or displayed on a text-only CRT. Input wasn’t interactive or real-time. These games were fun to play back then, but are kind of lame now. They still exist with regards to simple programming exercises. In fact, you can pound out a older type computer game in a few minutes if you know the basics of the C language.
Continue reading
Category Archives: Exercise
Read a Percentage Value
Here’s a thought experiment for you: How can you prompt a user to properly input a percentage value?
Continue reading
Appreciation for Depreciation
Back in the day, computer programming courses offered predictable assignments. These were number-crunching exercises, which had little flash and, yes, were boring. Today you can plot graphics, manipulate sound, and explore the web with your code. Back then, you’d do something dull like calculate depreciation.
Continue reading
Text Parsing Power
Parsing is an activity that programmers are often reluctant to do themselves. That’s because parsing can be a real pain in the rump. Not only that, but why write your own function when you can use specific libraries that handle the job for you? That’s a blessing, but it won’t let you escape from attempting this month’s Exercise.
Continue reading
Defensive Input
The task is rather simple: Prompt the user to input a value between 1 and 9. If you’ve read the first few chapters of any of my For Dummies C programming books, you could do that one easily. But what happens when the user doesn’t type a value in that range or — worse — they type text instead?
Continue reading
Merry Cumulative Song Exercise
In my C programming books, I often use the directions on a shampoo bottle as an example of basic programming:
1. Lather.
2. Rinse.
3. Repeat.
Another real-life example of programming techniques happens in music. Specifically, cumulative songs are representative of loops. This type of song includes 99 Bottles of Beer and the holiday favorite, The Twelve Days of Christmas.
Continue reading
Hex Parsing
Parsing is the process of sifting through a chunk of data to look for significant information. It’s a big topic.
Continue reading
The Hailstone Sequence
The Hailstone sequence is based on the theory is that you can perform a specific calculation on any positive integer to create a series of numbers. No matter which positive integer you start with, eventually the sequence ends with the value 1.
Continue reading
Flip That Bit
All the nonsense that takes place in programming happens because it’s possible to change the value of a bit from 0 to 1 and back again. The general concept is known as a toggle switch: The item can be set and reset between on and off positions.
Continue reading
Plotting Squares
The term sounds terrifying, but it doesn’t need to be: Data analysis is the process of using code to examine data and come up with some sort of conclusion. Obviously it helps to know the type of conclusion before you write the code. Only in science fiction does someone say, “What do you make all of those seemingly boring numbers, Mr. Computer?”
Continue reading