Counting Without Looping

Difficulty: ★ ★ ★ ★

One of the first lessons taught for any budding programmer is to to output sequential values, say one through ten. I use this example in my books to demonstrate how loops work. You can use for, while, and even goto to make the magic happen in the C language. But can you code such a program without using any looping keywords?
Continue reading →

Splitting Up a Real Number

In the C language, the flexible storage provided by a union allows me to access and examine the bits stored in a real number. Due to different data types accessing the same data, I can look at the bits in a float as a long int. From there, I can output the individual bits to see what each one represents, which was covered in last week’s Lesson. In this Lesson, I update the code to examine the individual parts of the binary32 format.
Continue reading →