1. Introduction to C
• Developed by: Dennis Ritchie at Bell Labs in 1972.
• Purpose: Initially developed for writing UNIX, later became
popular for system and application development.
• Why C is Popular:
o Efficiency: Code runs fast with minimal resource usage.
o Portability: Code written in C can be compiled and run on
different systems with little or no modification.
o Flexibility: Supports both high-level (modular) and low-level
(hardware) programming.
2. Key Features
• Procedural Language: Follows a step-by-step approach.
• Modular Approach: Code is divided into small parts (functions) for
easy maintenance.
• Low-level Access to Memory: Directly interacts with hardware,
which makes it suitable for system programming.
• Extensibility: Code can be easily extended with additional
functionality.
3. Basic Structure of a C Program
, Every C program follows a basic structure:
#include <stdio.h> // Header file
int main() { // Main function
printf("Hello, World!\n"); // Output statement
return 0; // Return control to OS
}
Explanation:
• #include <stdio.h> – Preprocessor directive that loads standard
input-output functions.
• main() – Entry point of the program, where execution starts.
• printf() – Displays text or values on the console.
• return 0; – Indicates that the program terminated successfully.
4. Basic Concepts in C
4.1 Data Types
• Primary Data Types:
o int – Stores integers (4 bytes).
o float – Stores decimal numbers (4 bytes).
o char – Stores a single character (1 byte).