Module 1 · Getting Started with C — topic 1 of 4
Introduction to C
C is a compiled, general-purpose language that gives you direct control over memory and hardware. It sits underneath operating systems, databases, compilers and embedded devices.
Learning objectives
- Explain what makes C a compiled, procedural, statically typed language
- Describe where C is used today and why
- Compile and run a first C program
Definition
C is a statically typed, procedural, compiled programming language standardised by ISO (C89, C99, C11, C17, C23). Source code is translated by a compiler into native machine code that runs directly on the processor.
Introduction
C was created by Dennis Ritchie at Bell Labs between 1969 and 1973 to rewrite the UNIX operating system. Before C, operating systems were written in assembly language, which is tied to one processor. C made it possible to write systems software once and move it to new machines by recompiling.
Half a century later, C is still everywhere: the Linux and Windows kernels, the CPython interpreter, SQLite, Git, network routers, car engine controllers and the firmware in your keyboard. When you learn C you learn how software actually talks to hardware.
Why it matters
C forces you to understand things other languages hide: how big an int is, where a variable lives in memory, what a pointer really is and who frees memory. These ideas come up in operating systems, computer architecture, data structures and compiler design — the core subjects of a B.Tech CS degree.
C is also the common ancestor of C++, Java, C#, JavaScript and Go. Their if, for, while, braces and operators come directly from C, so the syntax you learn here transfers immediately.
Detailed explanation
C is compiled. A compiler such as GCC or Clang reads your .c file and produces an executable containing machine instructions. Nothing interprets your code while it runs, which is why C programs start instantly and run fast.
C is procedural: a program is a collection of functions that call each other, starting from a function called main. There are no classes or objects built into the language.
C is statically typed: every variable has a type (such as int or double) fixed at compile time. The compiler uses the type to decide how many bytes to reserve and which machine instructions to use.
C gives you manual memory management. You can ask for memory at run time with malloc and you must give it back with free. This power is also C's biggest source of bugs, which is why later lessons spend time on it.
Syntax
#include <stdio.h>makes the standard input/output functions such asprintfavailable.int main(void)is where every C program starts;voidmeans it takes no arguments.printfprints formatted text;\nis a newline.return 0;tells the operating system the program finished successfully.
Code examples
Hello, C
Hello, C!
Every statement ends with a semicolon, and the body of main is enclosed in braces.
Printing a calculation
42
%d is a placeholder that printf replaces with an integer value.
More examples
A program with variables
C was created in 1972. In 2026 it is 54 years old.
Step-by-step explanation
int year_created = 1972;reserves memory for an integer and stores 1972 in it.int age = this_year - year_created;computes the difference at run time and stores 54.- The first
printfsubstitutesyear_createdfor%d. - The second
printfhas two%dplaceholders, filled in order bythis_yearandage. return 0;endsmainand reports success.
Expected output
Running “A program with variables” prints exactly:
Practical applications
- Operating system kernels (Linux, FreeBSD, most of Windows) are written in C.
- Embedded firmware in microcontrollers, medical devices and cars is mostly C.
- Language runtimes such as CPython and Lua are written in C.
- High-performance libraries (SQLite, OpenSSL, zlib) expose C interfaces that every other language can call.
Best practices
- Compile with warnings turned on (
-Wall -Wextra) from day one. - Use
int main(void)and always return a value frommain. - Keep one statement per line while you are learning; it makes compiler errors easier to locate.
Common mistakes
Forgetting the semicolon
Avoid
Prefer
In C a semicolon ends every statement. A missing one is a syntax error, usually reported on the line after the real mistake.
Leaving out #include <stdio.h>
Avoid
Prefer
Without the header the compiler does not know printf. Modern compilers reject the implicit declaration or warn loudly.
Important notes
- Since C99, reaching the closing brace of
mainwithout areturnbehaves asreturn 0;, but writing it explicitly is clearer. - This course uses C11. Code shown here also compiles as C17 and, with rare exceptions noted in later lessons, as C23.
Key takeaways
- C is a compiled, procedural, statically typed language standardised by ISO.
- Execution starts in
main;printffrom<stdio.h>prints text. - C gives direct access to memory, which brings both speed and responsibility.
Try it yourself
- 1Write a program that prints your name on one line and your branch (e.g. CSE) on the next.
Show hint
Use two
printfcalls, each ending with\n. - 2Print the product of 125 and 8 using
%dwithout calculating it yourself.
Finished reading? Mark it complete to update your dashboard.
Suggested practice
4 questions test this exact topic. Answers and explanations are revealed after you submit.
- BeginnerWhich statement best describes how a C program is executed?
- BeginnerWhere does execution of every hosted C program begin?
- BeginnerWhat does this program print?