Like a variable in the C language, a function has an address — a location in memory. This fact shouldn’t be surprising to you. After all, the function has to sit somewhere. And my guess is that location doesn’t change as the program runs.
Continue reading
C Language Neat Tricks #1
The C language holds the potential of being utterly terrifying, which is something I admire greatly. Many beginners, as well as foolhardy travelers from other languages, treat a lot of the C language constructs as absolutes when, in fact, they aren’t. Therefore I present this week’s Lesson, the first in an ongoing series about strange, beautiful, and frightening things in the C language.
Continue reading
Plotting Squares – Solution
The key to unlocking this month’s Exercise is not to go insane on the code that processes the solution. As I wrote in the Exercise post, with data analysis in C, it’s important to properly represent the data so that you can easily manipulate it.
Continue reading
More Heavily Weighted Random Numbers
One area where weighted random numbers come in to play is when doing a simulation. In a recent set of Exercises (May and June 2015), your mission was to craft a bowling game simulator. Like most simulations, the bowlings game simulator made use of random numbers. The problem in this situation is most decent bowlers don’t roll randomly.
Continue reading
Weighted Random Numbers
Random numbers are useful when simulating information and they add a degree of unpredictability to computer games. The problem programmers run into, especially with simulation, is that not everything is truly random. In many cases, some numbers need to be more random than others. The solution is to generate weighted random numbers.
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
Random Numbers with Decimals
The rand() function returns a pseudo-random number as a long int value. That value helps your code generate random numbers in the long int range. It can also be manipulated to yield random real number values, but that process involves . . . math.
Continue reading
To Form a More Perfect union
Next to enum, one of the more curious C language keywords is union. It’s tremendously unpopular. I would offer that it’s also not needed, but no one is talking about deprecating it.
Continue reading
The Mysterious enum Keyword
They’re the orphan keywords, urchins, unwanted, unused, unloved. Of the 32 C language keywords, a handful are seldom used. These include: auto, enum, register, union, and volatile.
Continue reading
Spelling Alphabet – Solution
This month’s task was to create code that translates spelling from a single word into the corresponding NATO phonetic alphabet words. For input such as hello the output would be something like:
Hotel Echo Lima Lima Oscar
Continue reading