← Back to C Course | Chapter 1: Introduction & Basics | Lesson 1 of 21

C परिचय

C एक छोटी, बहुत तेज़ programming language है जो computer असल में कैसे काम करता है उसके बहुत करीब बैठती है। कई दूसरी languages और यहाँ तक कि operating systems भी इससे बने हैं, जैसे किसी घर की नींव।

C क्या है?

C एक general-purpose, procedural programming language है जो objects की बजाय functions और statements के आस-पास बनी है।

यह आपको इस पर fine control देती है कि एक program memory और CPU का इस्तेमाल कैसे करता है, यही कारण है कि यह अभी भी उस software के बहुत सारे हिस्से में मौजूद है जिसे आप हर दिन बिना देखे इस्तेमाल करते हैं।

उदाहरण: What is C?

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;
}

C क्यों सीखें?

C सीखना आपको यह समझने पर मजबूर करता है कि असल में hood के नीचे क्या हो रहा है -- variables memory में कैसे occupy होते हैं, एक program machine instructions में कैसे compile होता है, और एक CPU उन्हें एक बार में एक कैसे execute करता है।

यह mental model सीधे C++, Java, और यहाँ तक कि Python जैसी languages में भी काम आती है।

उदाहरण: Why Learn C?

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;
}

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

c
// 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;
}

C के Applications

Operating system kernels (Linux, Windows के हिस्से), SQLite जैसे database engines और PostgreSQL का core, और ज़्यादातर दूसरी language runtimes खुद C में लिखी गई हैं, क्योंकि यह लगभग बिना किसी hidden overhead के predictable performance देती है।

उदाहरण: Applications of C

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;
}

C के Benefits

क्योंकि C native code में compile होता है और आपको pointers से memory manually manage करने देता है, इसमें लिखे programs higher-level languages में equivalent code से तेज़ होते हैं और कम RAM इस्तेमाल करते हैं -- इसकी कीमत यह है कि आप खुद उस memory के लिए ज़िम्मेदार होते हैं।

उदाहरण: Benefits of C

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;
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह मान लेना कि C किसी script की तरह interpreted है, जबकि एक C source file को run करने से पहले compile करना होता है (उदाहरण के लिए gcc main.c -o main)।
  2. C से built-in strings, classes या automatic memory management की उम्मीद करना, जब strings असल में char arrays हैं और memory आपकी ज़िम्मेदारी है।
  3. C को C++ से confuse करना और एक .c file में cout या class इस्तेमाल करना, जिसे C compilers reject कर देते हैं।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.