A Handy ASCII Table

Difficulty: Easy

Every coder needs an ASCII table. Even back in the old days, when I memorized such things as the Escape character was equal to 27 decimal, 0x1b hex, and had the keyboard shortcut ^[, I would glance at the ASCII table poster hanging on the wall to confirm that I was using the proper values in my code. And the poster looked cool.
Continue reading

Check Your Stock Gains

Difficulty: Hard

The challenge for last month’s Exercise was to generate a table showing a stock price updated every 30 minutes during the trading day. This month’s Exercise expands upon the process by having your code examine the stock price highs and lows and determine the greatest increase in stock value. This calculation means more than just finding the high and low values.
Continue reading

Watch the Stock Market

Difficulty: Medium

Stock prices fluctuate throughout the day based on news, fear, and speculation. If you own stock and desire the price to rise, you anxiously watch the stock tickers throughout the day, puzzled or delighted by the reactions. This month’s Exercise attempts to emulate such anxiety.
Continue reading

Balancing Accounts

Difficulty: Medium

Your bank receives two deposits or credits and three bills or debits. The credits cover the debits, meaning that your balance should never go below zero, but the bank has clever software: The bills are calculated first, which thrusts your account into negative territory complete with fees — even though the deposits cover the bills. Is this obnoxious behavior the result of greedy bankers or clever programming?
Continue reading

Positive, Negative, or Zero

The strcmp() function returns a value based on the comparison of two strings. The value is zero when the strings match, otherwise the value is positive or negative depending on how the strings compare. This result makes me wonder which other functions can return positive, negative, or zero values and whether the C library has a sign() function or similar that helps make such a determination.
Continue reading

Some Weighty Conversions

The three units of weight I’m familiar with are pounds, kilograms, and stone. For me, stone is the odd one. I’ve heard it used in Britain and it’s completely baffling to me, often requiring that I whip out a calculator to see what “14 stone” really means. Better, I could write code that converts between pounds, kilograms, and stone, which is the goal of this month’s Exercise.
Continue reading