Difficulty: Easy
I enjoy programming tables, rows and columns. The standard technique is to use a nested loop. In fact, when teaching nested loops, outputting a table is par for the course.
Continue reading
I enjoy programming tables, rows and columns. The standard technique is to use a nested loop. In fact, when teaching nested loops, outputting a table is par for the course.
Continue reading
The goal of the November 2018 Exercise on this blog was to count in “alphabedecimal,” or base 26 using the uppercase letters of the alphabet. The solution cycles from AAAA to ZZZZ flipping each character (or digit) one at a time, just as numbers are counted. The challenge is to do so without employing a nested loop.
Continue reading
Most functions are nice to strings. They manipulate the characters in a useful or clever way, returning an important value or an updated version of the text. But not every string function needs to be so kind, such as the one you write for this Exercise.
Continue reading
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
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
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
The C compiler preprocessor is a sneaky and powerful thing. I’m unsure of any other programming languages that have such a tool.
Continue reading
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
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
Removing redundancies from your C code may not be your first goal, but it’s something you can definitely find later. One example is when you must initialize a pair of arrays. Why use two loops when one will do?
Continue reading
Copyright © 1997-2024 by QPBC.
All rights reserved