Chapter 315 min read
History & Structure of C Language
Tracing the evolution of C from ALGOL to C23 and understanding the architecture of a C program.
Released1972
Core MottoSimple, Efficient, and Portable System Programming
CreatorsDennis Ritchie / Bell Labs
1. History & Evolution of C
Developed by Dennis Ritchie at Bell Labs in the early 1970s to construct the Unix operating system.
Evolved from ALGOL 60, BCPL, and B, drastically influencing modern languages like Java, C++, C#, PHP, and Python.
The Ancestry of C
ALGOL (1960):Introduced structured programming concepts to developers.
BCPL (1967):Designed by Martin Richards as a basic combined programming language.
B (1969):Created by Ken Thompson; directly served as the predecessor to C.
C Language (1972):Created by Dennis Ritchie at Bell Labs for building Unix.
Timeline of C Standards
K&R C (1978):First informal specification published by Kernighan and Ritchie.
ANSI C / C89 / C90:Standardized in 1989/1990 to solve implementation inconsistencies across compilers.
C99 (1999):Introduced inline functions, variable-length arrays, complex types, and double-slash (//) comments.
C11 (2011):Added multi-threading support, anonymous structs/unions, and atomic operations.
C17 / C18 (2018):Bug fixes and technical clarifications for C11 without adding major features.
C23 (2024):Modern revision introducing 14 new keywords and syntax refinements.
Classroom Discussion Starter
Why has C remained foundational in computer science for over 50 years despite the emergence of modern high-level languages?
Takeaway Goal: C provides unmatched execution efficiency, low-level memory control, and direct hardware accessibility while maintaining a portable procedural design.
2. The Preprocessor Section
Preprocessor directives begin with '#' and run before compilation starts.
They include header files (.h) and define global macros or constants.
Header File Inclusion (#include)
Purpose:Loads predefined library functions into the program.
Common Libraries:<stdio.h> for console I/O (`printf`, `scanf`), <math.h> for math operations, <string.h> for text handling.
c
#include <stdio.h>
#include <math.h>Macros & Constant Definitions (#define)
#define:Assigns fixed value representations or parameterized macro routines that execute faster than regular functions.
c
#include <stdio.h>
#define PI 3.14159
#define AREA(r) (PI * r * r) // Parameterized macro
int main() {
int radius = 5;
float area = AREA(radius);
printf("Area: %f
", area);
return 0;
}3. The main() Function & Global Section
The main() function acts as the single mandatory entry point for every C application.
Global Declarations
Placed outside all functions. Defines shared global variables, custom types, and forward function prototypes.
c
// Global Variables
int total = 0;
float average = 0.0;
// Forward Function Declaration
float area_of_square(float side);The main() Entry Point
Return Type:Defaults to `int`. Returning `0` signals successful program execution to the OS.
Semicolons:All C statements inside functions must terminate with a semicolon (;).
c
int main() {
/* Statements executed sequentially */
printf("Hello, World! \n");
return 0; // Signals successful program completion
}4. Subroutines & Comments in C
Programs are modularized using subroutines (user-defined functions) and documented with comments.
Types of Comments
Multi-Line Comments:Enclosed within /* ... */. Must be closed or an 'Unterminated comment' compiler error occurs.
Single-Line Comments:Starts with // and terminates at the newline. Statements placed on the same line after // are ignored.
c
/* Multi-line comment block:
Programmer: SCC Faculty
Activity: Basic Program Structure */
int age = 20; // Single line comment explaining variableComplete Program Architecture Example
Combines headers, global declarations, main entry, and subroutine definitions into a coherent program.
c
/* Headers Section */
#include <stdio.h>
#include <math.h>
/* Forward Declaration / Subroutine Prototype */
float area_of_square(float side);
/* Main Entry Function */
int main() {
float side = 5.50;
float area = area_of_square(side);
printf("Side=%5.2f Area=%5.2f
", side, area);
return 0;
}
/* Subroutine Function Definition */
float area_of_square(float side) {
float area = pow(side, 2); // math library function call
return area;
}