C Programming Exercises, Part 2: Fibonacci, Matrices and Algorithms
This collection contains practice problems commonly used in introductory C courses. Rather than memorizing answers, define the input range, select a data type that cannot overflow, separate parsing from computation, and test boundary cases.
Split-number property
For a given digit count n < 8, find every n-digit integer that equals the square of the sum of its left and right parts. When n is odd, the middle digit belongs to the left part.
| |
Fibonacci sequence
Print the first n Fibonacci numbers. Check the requested range because fixed-width integers eventually overflow.
Transpose a matrix
For a rectangular rows × cols matrix, output matrix[row][col] as matrix[col][row]. If a second array is allowed, the core operation is:
Normalize and count text
String exercises in the collection include copying, comparison, concatenation, character conversion, word counting, and removal of selected characters. Prefer bounded input:
Other exercises cover snake matrices, sorted insertion and deletion, phone books, factorial and polynomial sums, numerical approximations of e and sine, digit decomposition, Josephus-style counting, projectile rebound, and the monkey-and-peaches recurrence.
Compile with warnings enabled—for example -Wall -Wextra -Wpedantic—and add tests for zero, one, maximum input, duplicates, empty strings, and malformed input. Those habits are more valuable than any individual answer in a question bank.