A structure is a multi-variable, containing several variable types, all members of the same unit. Two declarations are required for a structure: The structure itself and the variable. Programmers get into trouble with structures when determining the variable’s size, using typedef as a structure shortcut, and when declaring structure pointers.
Continue reading
Author Archives: dgookin
Surrender to the Overflow
It’s a common question beginning programmers ask: “Why use different types of variables when every number can be expressed as a float?”
Continue reading
Calculating the Date of Easter – Solution
Easter occurs later this month, on the 16th. You can discover that date by using Google or by running the code solution for this month’s Exercise.
Continue reading
The strftime() Function
Being a C nerd, I occasionally browse the C library to discover new functions. Such an exercise is a must, not just for C but for any programming language. That’s because programmers can become complacent and rely upon the same old tricks. Only by reviewing the libraries, or by looking at other programmers’ code, can you learn new things.
Continue reading
Reducing Roman Numerals
I’m sure a mathematical solution exists to condense Roman numeral values. The values ending in 4 or 9 can be reduced, but whatever that solution is, it’s beyond me. So for my resolution to the Roman numeral reduction problem, I rely on strings instead of math.
Continue reading
Calculating the Date of Easter
Of all the annual holidays, Easter is the most difficult date to predict. It’s always a Sunday, but which one? It could land in March or April. Most people look at a calendar or (these days) use Google to find out when Easter occurs. Yet, you can write a program that tells you exactly when Easter falls.
Continue reading
From Decimal to Roman
The C language lacks a printf() conversion character to display Roman numerals. Therefore, if your code requires input of a decimal value, say 266, and output of a Roman numeral value, which would be CCLXVI, you must craft your own function.
Continue reading
From Roman to Decimal
Roman numerals are composed of letters, so it makes sense that their “values” are input and displayed as strings. To translate from that string into an integer, your program must convert each character into its corresponding decimal value. Sounds simple, right?
Continue reading
Decimal, Binary, Hexadecimal, Octal . . . Roman
As a programmer, you encounter new counting bases: binary, hexadecimal, and perhaps octal. As a human, you use decimal, but decimal is only a recent invention. Before 1600 or so, if you worked with numbers you probably used Roman numerals.
Continue reading
Detailed Examination of a CSV File – Solution
The task for this month’s Exercise is to read a CSV file, store the data, then manipulate and report. For my solution, I chose to create an array of structures in which to store the weather information.
Continue reading