Yet another fun way to mess with a matrix is to add its values to those in another matrix, creating a wonderful third matrix of the sums. Not everyone is going to agree that this notion is “fun.”
Continue reading
Author Archives: dgookin
Merging Arrays – Solution
This month’s Exercise is about coding a merge() function, which swallows two arrays and generates a third as output. The new array is “zippered” from the original arrays, alternating values from each.
Continue reading
Totaling a Grid’s Rows and Columns
Data in a matrix is entertaining and all that, but the point is usually to manipulate that data. The most basic form of manipulation I can conjure is to tally the rows and columns. Sounds like fun, but it took me a few attempts to get the code correct.
Continue reading
Merging Arrays
Difficulty: ★ ★ ☆ ☆
You have a number of options for merging values between two arrays. I suppose the solution you devise depends on how you interpret the word “merge.”
Continue reading
Playing with a Grid
Grids, or matrixes, are a common data thingy, as information often appears in tables. Being able to fold, spindle, and mutilate a grid is a common computer programming task, something to entertain your idle hours even if you have no pressing need to manipulate a matrix.
Continue reading
Adding Values from Two Arrays
In last week’s Lesson, I covered a function present in other programming languages but absent in C: concatenating arrays. This time, the topic is similar: adding two arrays. Yes, such functions exist in other languages, but in C you must write one yourself.
Continue reading
Concatenating Arrays
Yet another tool missing from C, but found in other programming languages, is the capability to stick together two arrays. The result is a single, larger array containing the elements from the two originals. With C, of course, you can always code your own function to handle the task.
Continue reading
A Compact for Loop – Solution
I hope you were able to cram a lot of expressions into a for loop statement, which is the challenge for this month’s Exercise. Even if you know this trick, it’s important to understand it’s limitations — which is something I discovered during my research.
Continue reading
Counting Terminal Rows and Columns
I enjoy programming a computer the old fashioned way, in the text mode terminal window. Yes, it’s now a sad little “app” floating on a graphical screen. This burden doesn’t remove the charm, but it does raise an interesting issue when you try to get text mode output just right: How many rows and columns are there in the terminal window?
Continue reading
A Compact for Loop
Difficulty: ★ ★ ☆ ☆
A for loop statement contains three parts: initialization, termination, and while-looping. If you omit any part, the compiler assumes the value one, or TRUE, as the value, so the statement for(;;)
becomes an endless loop. The opposite of omitting is loading up: You can state multiple initialization and while-looping expressions in the statement, which can make a for loop truly compact.
Continue reading