On this page
If C is on your first-semester timetable, it sits alongside maths, physics and a weekly lab (our guide to what you study in first year BTech covers the rest). Instead of copying lab programs, write many tiny programs, predict what each one does on paper, then let the compiler show you where you were wrong.
Why do first-semester students find C so hard?
You are not alone. In a 2001 assessment by McCracken and colleagues, 216 students from four universities averaged 22.89 out of 110 on a common set of programming problems.
A follow-up group led by Raymond Lister tested students from seven countries and found that many were weak at predicting what a short piece of code does, a skill the authors treat as a precursor to problem-solving. If you cannot yet trace code reliably, writing it will be much harder, so practise reading first.
How should you learn C in first semester?
Keep every practice program between 5 and 20 lines, and use the same four steps each time:
Read the program and write down what you expect it to print.
Compile and run it.
If the output differs, find the exact line where your thinking went wrong.
Change one value and predict again.
A 13-week plan in the usual order of a first C course:
Weeks 1-2: input, output and arithmetic. Average of three marks, Celsius to Fahrenheit.
Weeks 3-4: if and else. Leap year check, grade from marks, largest of three numbers.
Weeks 5-7: loops. Sum of digits, factorial, prime check.
Weeks 8-10: arrays and functions. Largest element, reversing an array.
Weeks 11-13: strings and pointers. String length without strlen, swapping two numbers through pointers.
Aim for three or four of these a week outside the lab. If one idea keeps blocking you, such as how pointers store addresses, the Fermi Concept Library covers computing concepts, each with its own lesson.
How do you trace C code by hand?
Tracing means running the program in your head and writing each variable's value on paper every time it changes. Take this loop:
int i = 1, total = 0;
while (i < 10) {
total = total + i;
i = i + i;
}
printf("%d %d", i, total);
Draw a table with a column for i, total and the condition, and add a row each time the condition is checked: 1 and 0, then 2 and 1, then 4 and 3, then 8 and 7, then 16 and 15, where i < 10 is false and the loop stops. The program prints 16 15. It is easy to answer 8 for i if you forget that the loop doubles i once more before the condition fails.
In the Lister study, students wrote "doodles" on scratch paper while answering. On questions where they drew a synchronized trace table, 77% of answers were correct; when the page stayed blank, 50% were. That sample was 56 students and shows a link, not proof, but the habit costs nothing to try. The same tracing method for Python output questions carries straight over to C.
What are the most common C errors, and how do you fix them?
Compile with warnings on every time, for example gcc -Wall -Wextra program.c. The GCC manual says -Wall enables warnings about constructions "that are easy to avoid", including checks that printf and scanf arguments match the format string. Despite its name, -Wall does not switch on every warning; -Wextra adds more.
Four errors you are likely to meet in the lab:
Writing scanf("%d", n) instead of scanf("%d", &n). The format check flags the missing ampersand.
Using sum before setting it to 0. The uninitialised-variable warning often catches this, but the manual says it depends on optimisation settings, so set every total yourself.
Writing if (avg = 100) instead of if (avg == 100). The parentheses warning flags an assignment where a true-or-false value is expected.
Integer division, where sum / n with two ints drops the decimal part. The -Wall warnings do not flag this; tracing does.
When the compiler prints a screen of errors, fix the first one and recompile, since one missing semicolon can trigger several later messages. Don't feel bad: a 2019 working group of computing educators titled its report Compiler error messages considered unhelpful. For logic bugs, print the key variables inside the loop and compare them with your trace table.
If a lab exercise runs but gives the wrong answer, the Fermi Problem Library has a step-by-step solver that explains the reasoning rather than printing an answer, so you can check your method line by line.
For a full lecture course, see IIT Kharagpur's NPTEL course Problem Solving through Programming in C by Prof. Anupam Basu. First-semester grades also count towards your CGPA, so pair this with our semester plan for improving your CGPA.



