Introduction to C
1. What is C language?
C Language is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972 at Bell Labs. It is often called the “mother of programming languages” because many modern languages like C++, Java, Python, and C# are built using its concepts
C is fast, portable, and close to the hardware, which makes it ideal for system software, operating systems, compilers, game engines, and embedded systems.
Simple Definition of C: –
C is a programming language that lets us communicate with the computer. Just like we use English to talk with people, programmers use C to give instructions to a computer.
Real-Life Example of C: –
Imagine you are controlling a fan with a remote.
When you press the ON button, the fan starts.
When you press SPEED UP, the fan rotates faster.
When you press OFF, it stops.
Behind this, there is a microcontroller (small computer chip) inside the remote and fan, and C language code runs inside that chip to understand your commands and control the motor speed.
Without C, your fan remote, washing machine, microwave, or even your car’s engine control unit would not function!
Other Real-Life Applications of C Language: –
- Operating Systems: Windows, Linux, macOS are written mostly in C.
- Embedded Systems: TVs, washing machines, digital watches, calculators.
- Game Development: Many classic game engines use C for speed.
- Databases: MySQL, Oracle are written in C.
- Compilers & Interpreters: Software that runs other programming languages (like Java/Python compilers) are built using C.
2. Why learn C in 2025?
You should learn C because it teaches you how computers really work – memory, logic, hardware interaction, and speed. It makes you a better programmer, no matter which language you use later.
C is the foundation of modern programming.
C programs run faster than Java/Python because they are closer to machine code.
Learning C improves your problem-solving skills and helps you understand how computers work internally.
Many job interviews for software engineers still include C programming questions.
Real-Life Example: Why Learn C?
Think about learning to drive a manual car:
In a manual car, you learn how the clutch, gear, and engine work.
Once you know manual, driving an automatic car becomes very easy.
C is like the manual car of programming.
When you learn C, you understand the core mechanics of programming (memory, pointers, logic). After that, learning Java, Python, or JavaScript feels like driving an automatic car – smoother and easier.
3. History of C language
The C programming language was developed in the early 1970s at Bell Laboratories (AT&T Bell Labs), USA by Dennis Ritchie. It was created to design the UNIX operating system, which needed a powerful yet flexible language.
C was not built in isolation—it evolved from earlier programming languages step by step.
Timeline of C Language Evolution: –
a. 1960 – ALGOL (Algorithmic Language)
First structured language, introduced concepts like loops & conditions.
However, it was not very practical for system programming.
b. 1967 – BCPL (Basic Combined Programming Language)
Developed by Martin Richards.
Mainly used for writing system software like compilers.
Influenced the creation of B language.
c. 1970 – B Language
Developed by Ken Thompson (also at Bell Labs).
Used in the early development of UNIX.
But it lacked advanced features like data types and structures.
d. 1972 – Birth of C Language
Dennis Ritchie developed C at Bell Labs.
Combined the best of B language + new features like data types, pointers, and structures.
Used to rewrite the UNIX operating system.
This made UNIX portable across different machines, a huge breakthrough!
f. 1978 – K&R C (First Book)
Dennis Ritchie & Brian Kernighan published “The C Programming Language”, also called the K&R C book.
This book became the first official documentation of C.
g. 1989 – ANSI C (Standardization)
The American National Standards Institute (ANSI) standardized C.
Ensured C code written on one computer could run on another without changes.
e. 1990 – ISO C
The International Organization for Standardization (ISO) approved ANSI C.
Known as ANSI/ISO C.
f. 1999 – C99 Standard
Introduced features like inline functions, long long int, variable-length arrays, etc.
g. 2011 – C11 Standard
Added features like multi-threading support, improved Unicode support, and better memory management.
h. 2023 – C23 Standard (Latest)
Introduced modern features like safer memory handling, better type checking, and small syntax improvements.
Still keeps C relevant in the modern world.
Real-Life Analogy: –
Think of C’s history like building a smartphone:
ALGOL & BCPL → Like old basic keypad phones.
B Language → A simple feature phone.
C Language (1972) → The first real smartphone, with all essential features.
ANSI C & Modern Standards → New versions of smartphones with more features, but the core idea remains the same.
4. Features of C
C is one of the most powerful and widely used programming languages in the world. It is called a middle-level language because it combines the features of low-level (close to hardware) and high-level (easy to use) languages.
Key Features of C Language: –
1. Simplicity
C has a simple structure with only 32 keywords. Easy to learn, yet powerful.Real-Life Example: Just like learning basic alphabets before writing essays, C provides a small set of building blocks to create anything.
2. Machine Independent (Portable)
C programs can run on any machine with little or no changes.Example: A program written on Windows can also run on Linux after recompilation.
3. Structured Programming Language
C allows you to break a big program into small functions (modules). This makes code easier to read, debug, and maintain.Example: Think of making a pizza – one person prepares the dough, another spreads the sauce, another adds toppings. Similarly, C divides tasks into functions.
4. Rich Library of Functions
C provides a large number of built-in functions for I/O handling, string manipulation, math operations, etc.Example: Instead of writing a function to calculate square root, you can directly use
sqrt() from the C math library.
5. Speed & Efficiency
C is very close to assembly language, so programs written in C are fast and memory-efficient.Example: That’s why operating systems like Windows and Linux are written in C, not Python or Java.
6. Memory Management with Pointers
C allows direct access to memory using pointers, giving more control to programmers.Example: In a video game, pointers can directly manipulate memory to update player health or position quickly.
7. Extensible (Can Grow Easily)
C programs can be extended by adding more functions without changing the existing code.Example: Like adding a new feature to a mobile app without rewriting the whole program.
8. Middle-Level Language
C can be used for both system programming (OS, compilers) and application programming (games, apps).Example: It’s like a Swiss army knife – useful for small tasks and big projects.
These features make C fast, efficient, and still relevant in 2025.
Why These Features Matter?
Because of these features, C is still used in:
Operating Systems (Windows, Linux, iOS)
Embedded Devices (TVs, Cars, Smartwatches)
Databases (MySQL, Oracle)
Compilers & Interpreters (for Java, Python, etc.)
5. How C is different from other languages?
Key Differences of C with Other Languages: –
C vs C++
C: Procedure-oriented (focus on functions).
C++: Object-oriented (focus on objects, classes, inheritance).
Example:
C is like building a house by step-by-step manual work (brick, cement, paint).
C++ is like using pre-designed modules (rooms, furniture) that can be reused.
C vs Java
C: Compiled language, directly converted to machine code → very fast.
Java: Compiled into bytecode, then executed by JVM (Java Virtual Machine) → slower but portable.
Example:
C is like writing directly in English to a local person (fast communication).
Java is like writing in English, then translating into many languages so people everywhere can understand (slower, but universal).
C vs Python
C: Low-level, requires manual memory management, more code.
Python: High-level, automatic memory management, fewer lines of code.
Example:
C is like driving a manual car – full control but needs more effort.
Python is like driving an automatic car – easier but less control.
Execution Speed
C: Very fast (close to hardware).
Java/Python: Slower (because of interpreters or virtual machines).
Example:
C is like cooking raw food at home (fast & optimized), while Python/Java is like ordering food online (convenient but takes time).
Memory Management
C: Manual memory allocation with
malloc()andfree().C++: Uses constructors/destructors, still offers manual control.
Java/Python: Automatic garbage collection.
Example:
C is like washing your own clothes by hand.
Java/Python is like using a washing machine – easy but you don’t control every detail.
Learning Curve
C: Harder for beginners but builds strong foundation.
Python: Easier for beginners (simple syntax).
Example:
Learning C is like learning mathematics from scratch → tough but rewarding.
Learning Python is like using a calculator → quick and simple, but you may miss the fundamentals.
6. Structure of a C program
Basic Structure of a C Program
- Header File
- Global Declarations (Optional)
- Main Function
- Body of the Program(Local Declarations, Statements / Logic, Return Statement)
- User-Defined Functions (Optional)
Header File: –
-
Lines starting with
#are preprocessor commands. -
Example:
#include <stdio.h>→ tells the compiler to include standard input-output library.
🍭Example: Think of it like importing ingredients before cooking.
Global Declarations (Optional): –
-
Variables or constants declared outside functions.
-
They can be used by all functions in the program.
🍭Example: Like a rulebook that everyone in the house follows.
Main Function: –
-
Every C program must have a
main()function. -
It is the entry point where execution starts.
🍭Example: Like the main door of your house – everything begins here.
Body of the Program: –
a. Local Declarations –
Variables declared inside functions (like int number = 5;).
They can only be used inside that function.
🍭Example: Like keeping your personal wallet inside your room – only you can access it.
b. Statements / Logic –
The body of the program where actual tasks happen.
Example: printf("Hello, World!"); → displays output.
🍭Example: Like cooking food in the kitchen – the real work happens here.
C. Return Statement –
Used to send a value back to the calling function.
return 0; → indicates successful execution.
🍭Example: Like telling your boss the work is completed successfully.
User-Defined Functions (Optional): –
-
Functions created by the programmer.
-
Helps break large programs into smaller parts.
🍭Example: Like assigning different household chores to different family members.
Code<>
#include <stdio.h> // Header File or Preprocessor
// Global Variable
int mangoes = 10;
// Function Declaration
void greet();
int main() {
// Local Variable
int guavas = 20;
// Logic
printf("Numbers of Mangoes: %d\n", mangoes);
printf("Numbers of Guavas: %d\n", guavas);
// Function Call
greet();
return 0; // End of Program
}
// User Defined Function
void greet() {
printf("Hello from user-defined function!\n");
}
Output: –
Numbers of mangoes: 10
Numbers of Guavas: 20
Hello from user-defined function!
7. First Program in C
Fastest C Program (Hello World)
code<>
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
Output: –
Hello, World!
This is the most basic and fast program every beginner runs first.
-
#include <stdio.h>→ Allows usingprintf. -
int main()→ Entry point of program. -
printf("Hello, World!\n");→ Prints text on screen. -
return 0;→ Ends the program successfully.