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.
1 |
|
Fibonacci sequence
Print the first n Fibonacci numbers. Check the requested range because fixed-width integers eventually overflow.
1 | unsigned long long a = 0, b = 1; |
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:
1 | for (int r = 0; r < rows; ++r) |
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:
1 | char line[256]; |
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.