C Introduction
The phone in your pocket, the ATM at the corner, the Wi-Fi router at home and the software inside a car's engine all have something in common: a large part of their code is written in C. C is more than fifty years old, yet it still runs much of the world's computing.
In this lesson you will learn what C is, where it is used, how a C program turns into something your computer can run, and what makes C different from languages such as Python and Java.
What is C?
C is a general-purpose programming language. Dennis Ritchie created it at Bell Labs in the early 1970s, mostly in 1972, so that he and Ken Thompson could rewrite the Unix operating system in a language that was easier to work with than assembly code but still fast.
Three ideas describe C well:
- Compiled. You write C in a text file. A program called a compiler translates it into machine code, the instructions your processor understands directly. The result is a separate program file you can run again and again.
- Small and close to the hardware. C has only a few keywords and a small standard library. It lets you work with memory addresses directly through pointers, which is why people sometimes call it "portable assembly".
- Procedural. A C program is built from functions, named blocks of code that each do one job. C has no classes or objects like Java has.
Here is a complete C program. Do not worry about every symbol yet; the next lessons explain each line.
#include <stdio.h>
int main(void)
{
printf("Namaste from Pune!\n");
return 0;
}Namaste from Pune!
printf prints text on the screen, \n moves to a new line, and return 0; tells the operating system that the program finished without errors.
Where is C used today?
C is everywhere that speed, small size or direct control of hardware matters. Some well-known examples:
| Area | Examples written mainly in C |
|---|---|
| Operating systems | The Linux kernel, large parts of Windows and macOS |
| Embedded devices | Microcontrollers in washing machines, cars, routers and medical devices |
| Databases | SQLite, PostgreSQL, Redis |
| Programming languages | CPython (the standard Python interpreter), the PHP interpreter |
| Tools and servers | Git, curl, the nginx web server |
When you run a Python script, the interpreter that runs it is a C program. When you push code with Git, C code does the work. Learning C helps you understand what is happening underneath the tools you already use.
How a C program runs
Python reads your code and runs it line by line through an interpreter. C works differently. You first compile the whole program, and then you run the result.
- You write source code in a file that ends in
.c, for examplehello.c. - The compiler (GCC or Clang) checks it for errors and translates it into machine code.
- The compiler produces an executable, a file such as
helloon Linux and macOS orhello.exeon Windows. - You run the executable. It no longer needs the compiler or the source file.
In a terminal, the two steps look like this:
gcc -std=c23 -Wall -Wextra hello.c -o hello
./helloThe first command compiles hello.c into a program called hello. The second command runs it. You will install a compiler in Install GCC/Clang & VS Code and learn what every part of this command means in Your First C Program.
Because the translation happens before the program runs, a compiled C program starts instantly and runs very fast. The cost is that you must compile again every time you change the code.
A slightly bigger program
Programs become useful when they store values and calculate with them. This one works out a batsman's strike rate, which is the runs scored for every 100 balls faced.
#include <stdio.h>
int main(void)
{
int runs = 48;
int balls = 32;
double strike_rate = runs * 100.0 / balls;
printf("Rohan scored %d runs off %d balls.\n", runs, balls);
printf("Strike rate: %.2f\n", strike_rate);
return 0;
}Rohan scored 48 runs off 32 balls. Strike rate: 150.00
int stores whole numbers and double stores numbers with a decimal point. Inside printf, %d is replaced by a whole number and %.2f by a decimal number with two digits after the point. Every C program you write will use ideas like these.
C compared with Python and Java
| Feature | C | Python | Java |
|---|---|---|---|
| How it runs | Compiled to machine code | Run by an interpreter | Compiled to bytecode, run by the JVM |
| Types | Static: you declare each variable's type | Dynamic: types are checked while running | Static |
| Memory | You request and free memory yourself | Automatic (garbage collector) | Automatic (garbage collector) |
| Safety checks | Very few; no array bounds checking | Many | Many |
| Typical speed | Very fast | Slower | Fast |
C trusts the programmer. If you read past the end of an array, C does not stop you. The program may print rubbish, crash, or quietly corrupt data. These memory bugs are behind many security problems in real software, so this course teaches safe habits from the start: turning on compiler warnings, using size-limited functions and checking every input.
Versions of C
C has changed over the years through official standards, documents that define exactly what the language means. The main versions are K&R C (1978), C89/C90, C99, C11, C17 and C23, the current standard, published in 2024. This course teaches C23 and points out where older code you may meet in books, exams or projects looks different. You can read the full story in C Standards: K&R to C23.
Why learn C?
- You learn how memory, pointers and the stack really work, which makes you better in every other language.
- Syntax from C appears in C++, Java, JavaScript, C# and PHP: braces, semicolons,
forloops andifstatements all look similar. - C is the main language for embedded systems and operating system work.
- Many university courses and technical interviews test C concepts such as pointers and memory.
Common misunderstandings
- "C is old, so it is dead." C is still updated, and the C23 standard added many modern features. New systems code is written in C every day.
- "C is the same as C++." They share history and syntax, but they are separate languages with separate standards.
- "If it compiles, it is correct." A C compiler accepts many programs that are wrong. Warnings and testing are essential.
Key points
- C is a compiled, procedural, general-purpose language created by Dennis Ritchie at Bell Labs around 1972.
- A compiler turns
.csource files into an executable that runs directly on the processor. - C powers operating systems, embedded devices, databases and interpreters such as CPython.
- C gives you direct control of memory but performs very few safety checks, so careful habits matter.
- C23 is the current standard; this course teaches it and shows the older forms you will still see.
Exercise
Look at the strike-rate program above. Without running anything, write down what the output would be if runs were 75 and balls were 50. Then list two pieces of software you use every week that are written mainly in C.
Show solution
With 75 runs off 50 balls, the strike rate is 75 × 100 / 50 = 150, so the output is:
Rohan scored 75 runs off 50 balls. Strike rate: 150.00
Possible answers for the second part: Git, the Python interpreter (CPython), SQLite inside your phone's apps, or the Linux kernel inside an Android phone.
Quick Quiz
1. Who created the C language?
Dennis Ritchie created C at Bell Labs in the early 1970s to rewrite the Unix operating system.
2. What does a C compiler do?
The compiler translates the whole .c file into machine code before the program runs.
3. Which statement about C is true?
C performs very few safety checks, which makes it fast but means you must avoid memory bugs yourself.
4. What is the current C standard taught in this course?
C23, published in 2024, is the current standard; C17 and older versions are still common in existing code.
Learn C with a mentor
Free lessons get you started. Our Java, C & C++ Programming training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
