C History & Features
History of C
Dennis Ritchie designed C at Bell Labs in 1972 as a tool for rewriting the Unix operating system, which had previously been written in assembly for each specific machine. C let Unix become portable across hardware for the first time.
Example: History of C
#include <stdio.h>
int main() {
printf("C was created by Dennis Ritchie at Bell Labs in 1972.");
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Direct Memory Access
Pointers let a variable store the memory address of another variable instead of a value directly, so you can read or modify data indirectly. This is what makes techniques like dynamic memory allocation and efficient array/string handling possible in C.
Example: Direct Memory Access
#include <stdio.h>
int main() {
int value = 42;
int *ptr = &value;
printf("Address: %p, Value via pointer: %d", (void*)ptr, *ptr);
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Speed and Efficiency
With no garbage collector, virtual machine, or interpreter layer between your code and the processor, a compiled C program spends its execution time doing actual work rather than managing runtime overhead -- one reason it's still chosen for performance-critical systems.
Example: Speed and Efficiency
#include <stdio.h>
int main() {
long sum = 0;
for (long i = 0; i < 1000000; i++) {
sum += i;
}
printf("Sum: %ld", sum);
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Modularity
C encourages breaking a program into small, independent functions, each handling one task and callable from anywhere in the file (or other files, via headers). This mirrors how larger real-world codebases stay maintainable as they grow.
Example: Modularity
#include <stdio.h>
int square(int n) {
return n * n;
}
int main() {
printf("Square: %d", square(5));
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Extensibility
The standard library and third-party libraries expose reusable functionality -- string handling, math, file I/O -- through header files you #include, so you're not stuck rewriting common operations that other programmers have already solved well.
Example: Extensibility
#include <stdio.h>
#include <string.h>
int main() {
char name[] = "C Language";
printf("Length: %zu", strlen(name));
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Chapter Quiz — Complete all 21 topics to unlock
0/21 topics done
Complete these topics first:
- C Introduction
- C History & Features
- C Environment Setup
- C First Program
- C Syntax & Structure
- C Statements
- C Comments
- C Keywords & Identifiers
- C Data Types
- C Character Data Type
- C Numeric Data Types
- C Decimal (Floating-Point) Numbers
- C sizeof Operator
- C Extended Data Types
- C Type Conversion
- C Booleans
- C Variables
- C Changing Variable Values
- C Multiple Variables
- C Constants
- C Fixed-Width Integers