Your first semester teaches you C syntax. It does not teach you how to think in it, and that gap is why the lab exam feels harder than the lectures. These 25 problems close it. They are ordered so each one uses something the previous one taught, and every single one is solvable with what a first semester covers.
Do not look up solutions. A problem you struggled with for forty minutes and then solved teaches you more than ten you copied. If you are properly stuck after forty minutes, read the hint under the problem — the hints deliberately point at the idea, not the code.
Set 1 — Getting the machine to do arithmetic (problems 1–5)
These look trivial. They are not, because the mistakes you make here are the same
mistakes you will make in every later program: integer division, operator precedence, and
forgetting that scanf needs an address.
- Seconds to time. Read a number of seconds, print it as hours, minutes and seconds. Hint: this is two divisions and two remainders, in the right order.
- Average without integer division bugs. Read five integers, print the average correct to two decimal places. Hint: if your answer is always a whole number, you divided two ints.
- Simple interest and compound interest side by side. Read principal,
rate and years. Print both. Hint: you need
pow()from math.h, and you need to compile with-lmon Linux. - Swap two numbers without a third variable. Hint: addition and subtraction. Then think about what happens if the numbers are very large.
- Last digit, first digit. Read any integer and print its first and last digit. Hint: last is one remainder. First needs a loop, or a logarithm if you are feeling clever.
Set 2 — Decisions (problems 6–10)
The exam favourite. Most marks are lost here to conditions that are logically right but written in a way C reads differently.
- Leap year. Divisible by 4, but not by 100, unless also by 400. Hint: write the condition as one boolean expression, then read it out loud to check it matches that sentence.
- Largest of three numbers without using
&&. Hint: nested ifs. This is here to make the next problem feel easy. - Quadratic roots, all three cases. Real and distinct, real and equal,
complex. Print complex ones as
a + bi. Hint: the discriminant decides, and a float comparison to exactly zero is a trap. - Character classifier. Read one character, say whether it is a vowel, a consonant, a digit, or something else. Hint: handle upper and lower case without writing ten conditions.
- Electricity bill with slabs. First 100 units at one rate, next 100 at another, rest at a third. Hint: the second slab is not charged at the second rate for all units — only for the units inside that slab. Almost everyone gets this wrong the first time.
Set 3 — Loops (problems 11–16)
- Reverse a number. 1234 becomes 4321. Hint: remainder to pull the last digit off, division to shorten the number, multiply your answer by 10 each step.
- Armstrong numbers under 1000. Hint: you already wrote the digit extraction in problem 11.
- Prime check, then all primes under N. Hint: you do not need to check divisors past the square root, and you should be able to say why.
- GCD by Euclid's algorithm. Hint: three lines. If yours is fifteen, look up the algorithm — it is worth knowing properly.
- Fibonacci to N terms, then the Nth term only. Hint: the second version needs two variables, not an array.
- Pattern printing. A right triangle, an inverted one, and a pyramid of stars. Hint: the outer loop is rows. The inner loops are spaces first, then stars. Draw it on paper with row numbers before writing code.
Set 4 — Arrays and strings (problems 17–22)
- Second largest element in one pass through the array. Hint: two variables, and think carefully about duplicates.
- Reverse an array in place. No second array. Hint: two indexes walking towards each other.
- Linear search, then binary search on a sorted array. Count the comparisons each makes. Hint: printing the comparison count is the point — that is where the difference stops being abstract.
- Palindrome string, ignoring case and spaces. Hint: same two-index idea as problem 18.
- Word count in a sentence. Handle multiple spaces between words. Hint: count transitions from space to non-space, not spaces.
- Matrix addition and transpose. Hint: transpose in place only works for square matrices, and only if you loop over half the matrix.
Set 5 — Functions and the beginning of real programs (23–25)
- Factorial, iterative and recursive. Then find the largest N your
program handles before the answer goes wrong. Hint: it is smaller than you expect, and
the reason is the size of an
int. - A menu-driven calculator. Loop until the user picks exit. Each operation is its own function. Hint: this is the first program where structure matters more than cleverness.
- Student marks system. Store roll number, name and three subject marks for N students using a structure. Print the topper and the class average. Hint: this is a small program that uses everything above, which is exactly why it is last.
How to actually use this list
Two or three problems a day, not fifteen on a Sunday. The point is repetition across days, because that is what moves things into memory you can use under exam pressure.
Type every program out. Do not copy from a friend's file and change variable names — your hands need to learn where the semicolons go, and the lab exam is handwritten or typed under time pressure, not pasted.
When a program does not compile, read the first error only. The rest are usually knock-on effects of that one, and beginners waste hours chasing error number nine.
What comes after this
Once you can do all 25 without help, you know enough C to build something small and real. That is a genuinely different feeling from finishing a syllabus, and it is the point where most people stop — they keep doing exercises forever because exercises are safe and building something is not.
Do not stop there. Pick something tiny, finish it badly, and show it to someone. A finished ugly thing teaches you more than a hundred more practice problems.