C का इतिहास और विशेषताएँ
C का इतिहास
Dennis Ritchie ने 1972 में Bell Labs में C को Unix operating system दोबारा लिखने के एक tool के तौर पर design किया, जो पहले हर specific machine के लिए assembly में लिखा गया था। C ने पहली बार Unix को hardware में portable बनाया।
उदाहरण: History of C
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Print formatted text to the screen
printf("C was created by Dennis Ritchie at Bell Labs in 1972.");
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Direct Memory Access
Pointers एक variable को सीधे एक value की बजाय किसी दूसरे variable का memory address store करने देते हैं, ताकि आप data को indirectly पढ़ या modify कर सकें।
यही वजह है कि C में dynamic memory allocation और efficient array/string handling जैसी techniques possible हैं।
उदाहरण: Direct Memory Access
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare value and set it to 42
int value = 42;
int *ptr = &value;
// Print formatted text to the screen
printf("Address: %p, Value via pointer: %d", (void*)ptr, *ptr);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Speed और Efficiency
आपके code और processor के बीच कोई garbage collector, virtual machine, या interpreter layer न होने से, एक compiled C program अपना execution time actual work करने में लगाता है, runtime overhead manage करने में नहीं -- यही एक कारण है कि यह अभी भी performance-critical systems के लिए चुना जाता है।
उदाहरण: Speed and Efficiency
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare sum and set it to 0
long sum = 0;
// Loop: repeat while the condition holds
for (long i = 0; i < 1000000; i++) {
sum += i;
}
// Print formatted text to the screen
printf("Sum: %ld", sum);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Modularity
C एक program को छोटे, independent functions में तोड़ने को बढ़ावा देती है, हर एक एक task handle करता है और file में कहीं से भी (या headers के जरिए दूसरी files से भी) callable होता है। यह दिखाता है कि बड़े real-world codebases बढ़ने के साथ maintainable कैसे रहते हैं।
उदाहरण: Modularity
// Include standard input/output (printf, scanf)
#include <stdio.h>
int square(int n) {
// Send n * n back to the caller
return n * n;
}
// Program execution starts in main()
int main() {
// Print formatted text to the screen
printf("Square: %d", square(5));
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
Extensibility
Standard library और third-party libraries reusable functionality -- string handling, math, file I/O -- को header files के जरिए expose करती हैं जिन्हें आप #include करते हैं, ताकि आपको common operations दोबारा लिखने में फंसना न पड़े जिन्हें दूसरे programmers पहले ही अच्छे से solve कर चुके हैं।
उदाहरण: Extensibility
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Include string functions (strlen, strcpy, ...)
#include <string.h>
// Program execution starts in main()
int main() {
char name[] = "C Language";
// Print formatted text to the screen
printf("Length: %zu", strlen(name));
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
- C को पुराना होने की वजह से obsolete मान लेना, जबकि यह अभी भी operating systems और embedded software के पीछे की language है।
- यह मान लेना कि C आपके लिए array bounds या pointer validity check करता है, जबकि यह बिना किसी safety net के direct memory access देता है।
- यह सोचना कि सारे C compilers same तरह behave करते हैं, जबकि standard (C89, C99, C11) और compiler extensions यह बदल सकते हैं कि क्या allowed है।
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