C परिचय
In this page:
C क्या है?
C एक general-purpose, procedural programming language है जो objects की बजाय functions और statements के आस-पास बनी है।
यह आपको इस पर fine control देती है कि एक program memory और CPU का इस्तेमाल कैसे करता है, यही कारण है कि यह अभी भी उस software के बहुत सारे हिस्से में मौजूद है जिसे आप हर दिन बिना देखे इस्तेमाल करते हैं।
उदाहरण: What is C?
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare total and set it to 0
int total = 0;
// Loop: repeat while the condition holds
for (int i = 1; i <= 5; i++) {
total += i;
}
// Print formatted text to the screen
printf("Total: %d", total);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
C क्यों सीखें?
C सीखना आपको यह समझने पर मजबूर करता है कि असल में hood के नीचे क्या हो रहा है -- variables memory में कैसे occupy होते हैं, एक program machine instructions में कैसे compile होता है, और एक CPU उन्हें एक बार में एक कैसे execute करता है।
यह mental model सीधे C++, Java, और यहाँ तक कि Python जैसी languages में भी काम आती है।
उदाहरण: Why Learn C?
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare x and set it to 10
int x = 10;
// Print formatted text to the screen
printf("Value: %d, Size in memory: %zu bytes", x, sizeof(x));
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
C कैसे काम करता है
एक C program पहले एक compiler द्वारा एक intermediate object file में translate होता है, फिर raw machine instructions वाले एक native executable में link होता है।
Interpreted languages के उलट, चलते समय आपके code को translate करने वाला कोई runtime नहीं होता -- CPU सीधे आपकी logic execute करता है।
उदाहरण: How C Works
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Print formatted text to the screen
printf("This program runs as compiled machine code, no interpreter needed.");
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
C के Applications
Operating system kernels (Linux, Windows के हिस्से), SQLite जैसे database engines और PostgreSQL का core, और ज़्यादातर दूसरी language runtimes खुद C में लिखी गई हैं, क्योंकि यह लगभग बिना किसी hidden overhead के predictable performance देती है।
उदाहरण: Applications 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 powers OS kernels, database engines, and language runtimes.");
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
C के Benefits
क्योंकि C native code में compile होता है और आपको pointers से memory manually manage करने देता है, इसमें लिखे programs higher-level languages में equivalent code से तेज़ होते हैं और कम RAM इस्तेमाल करते हैं -- इसकी कीमत यह है कि आप खुद उस memory के लिए ज़िम्मेदार होते हैं।
उदाहरण: Benefits of C
// Include standard input/output (printf, scanf)
#include <stdio.h>
// Program execution starts in main()
int main() {
// Declare value and set it to 100
int value = 100;
int *ptr = &value;
// Print formatted text to the screen
printf("Direct memory control via pointer: %d", *ptr);
// Return 0 to signal that the program finished successfully
return 0;
}
Login to try C/C++/Java/PHP code in the editor
- यह मान लेना कि C किसी script की तरह interpreted है, जबकि एक C source file को run करने से पहले compile करना होता है (उदाहरण के लिए
gcc main.c -o main)। - C से built-in strings, classes या automatic memory management की उम्मीद करना, जब strings असल में
chararrays हैं और memory आपकी ज़िम्मेदारी है। - C को C++ से confuse करना और एक
.cfile मेंcoutयाclassइस्तेमाल करना, जिसे C compilers reject कर देते हैं।
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