The solution for this month’s Exercise involves two steps. The first is to generate a random value from 1 to 365 (inclusive) as a day-of-the-year value. The second is to determine upon which month and day that value falls. That part may offer more difficulty than you anticipate.
Continue reading
Category Archives: Solution
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
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
The CSV File – Solution
This month’s Exercise, required you to read a CSV file, extract specific information, and output a table. It’s basically a file-reading exercise, though you must also translate the input into the proper value. And you must output the month as a string.
Continue reading
Find the Error: Pointers, Structures, and Files – Solution
It took me a while to figure out what was wrong with this month’s Exercise file. It became an obsession! Of course, I was working with a more complex version — the original code. In that code, the information is written several times to the file, and it becomes very obvious that something is wrong. But when the data is written only once, it’s tough to know whether a problem exists.
Continue reading
Ranking Scores – Solution
This month’s Exercise is to create an array of six players, assign each a random score (1 to 100), then display the player’s scores by rank. The first problem you most likely encountered was how to keep the player’s number and score together.
Continue reading
When You Need a Function – Solution
For my solution to this month’s Exercise, I crafted the ask() function. That’s because the original code prompts three times with a question string and an answer buffer, which is the repetitive part of the program I chose to cast into a function.
Continue reading
The Curse of Typecasting – Solution
I hope you didn’t find this month’s Exercise too daunting. In fact, it’s pretty basic stuff, but often something you might forget. In fact, the compiler may remind you when you attempt to pass an argument to a function and it’s of the wrong type.
Continue reading
Take Your Turn – Solution
This month’s Exercise is to simulate turns in a game of tic-tac-toe (naughts and crosses). So the solution requires that you randomly work through available squares in the game matrix, alternating placement of an 'x'
or 'o'
token.
Continue reading
Your Card is Valid – Solution
Implementing a written algorithm is something you do frequently as a C language programmer. You’re given a set of directions and your job is to translate that English into computer code — and make that code work.
Continue reading