C Programming for Beginners: 15-Day Hands-On Practical Course
C PROGRAMMING · LESSON 1

Introduction to C and Your First Program

Understand how a C program becomes a running application, then write 4 working programs using main() and printf().

Code on a laptop screen

Concepts

💡

What is programming?

Writing step-by-step instructions that a computer can follow to solve a problem.

🚀

Where is C used?

Operating systems, embedded devices, game engines, databases, drivers and the tools other languages are built on.

📄

Source code

The human-readable text you write, saved in a file ending with .c.

⚙️

Compiler vs interpreter

A compiler translates the whole program first. An interpreter translates and runs it line by line.

Compiler vs Interpreter

FeatureCompiler (C)Interpreter (e.g. Python)
TranslationWhole program at onceLine by line while running
OutputExecutable fileNo separate executable (usually)
Speed at run timeUsually fasterUsually slower
ErrorsShown before the program runsShown when that line runs

How Source Code Becomes a Program

Click a stage to see what happens and the gcc command that shows it.

Program Anatomy

Click any line to see what it does.

Select a line.

Exercise 1: Install or Open a C Compiler

Verify with gcc --version. Compile with gcc hello.c -o hello, then run ./hello (Windows: hello.exe).

Command Cheat Sheet

Type these in a terminal (Command Prompt, PowerShell, Terminal). Commands are coloured: command -flag file.c. Click Copy to copy one.

CommandWhat it doesWhere

Exercises 2-4: Your 4 Programs

Each program shows its code and the output produced by the built-in simulator. Download the file, compile it on your own computer, and tick it off.

Printf Reference

SpecifierPrintsExample
%dInteger42
%f / %.2fDecimal number3.14
%cOne characterA
%sStringRiya
%-10s / %5dLeft / right aligned widthpadding
%%A percent sign%
EscapeMeaning
\nNew line
\tTab
\\Backslash
\"Double quote

Live C Playground: Auto-Run, Errors and Fixes

Every C program must start at main(). Type C code below: it is colour-highlighted, checked and run on every keystroke. Supports printf, scanf, int/float/char variables, char name[N] text and basic maths. Turn on Smart suggestions for autocomplete, and use Format code to tidy any code into a clean structure. if/for/while come in later lessons.

Terminal

When the program asks for input, type in the terminal and press Enter.

Problems and suggestions

Timetable Builder

One row per line as Day,Time,Subject. The tool writes the C program and shows its output.

Common Errors and Fixes

MistakeWhat you seeFix
Missing ;"expected ';'" errorEnd each statement with a semicolon
No #include Warning about implicit declaration of printfAdd the include at the top
Printf or PRINTFUndefined reference or implicit declarationC is case sensitive: use printf
Missing closing quote"missing terminating" errorClose every string with "
Forgot \nOutput runs together on one lineAdd \n at the end of the text
Wrong file saved"No such file"Run the command in the folder containing the .c file

Deliverable Checklist

    Quick Quiz

    0% Complete