Lesson 1 — Beginner

C Programming kya hai — Introduction

C ek powerful general-purpose language hai jo 1972 mein bani aur aaj bhi duniya ke sabse important software usi mein bane hain. Is lesson mein hum samjhenge ki C hota kya hai, kyun itni important hai, aur tumhara pehla C program kaise compile aur chalta hai.

⏱ 12 min• Beginner• Kuch nahi

C programming kya hai

WHAT

C ek general-purpose, mid-level programming language hai jo 1972 mein Dennis Ritchie ne Bell Labs mein banayi. Ye high-level jaisi padhi jaati hai (English jaisa syntax) aur low-level jaisi kaam karti hai (memory aur hardware ke paas access).

WHEN

Jab bhi tez, resource-efficient program chahiye — OS, embedded systems, drivers, compilers, databases — C sabse pehle choice hai. Interviews aur college exams mein bhi C hi base language mana jaata hai.

WHERE

Linux kernel pura C mein hai, Python ka interpreter bhi C mein likha gaya hai, har router aur smart device ke andar C code chalta hai. Tumhara phone bhi C se bane software par hi chalta hai.

C ka ek line ka funda: syntax simple, power full. Itni chhoti language mein tum memory tak direct pahunch sakte ho — isi liye 50 saal baad bhi C industry mein raj kar rahi hai.

Yaad rakho: C ko "mid-level language" kehte hain — kyunki ye high-level (Python, Java jaisi aasaan) aur low-level (assembly jaisi hardware ke paas) dono ke beech mein hai. Ye line exam mein aksar aati hai.

C ki history — CPL se C tak

1967 : BCPL (Basic Combined Programming Language) — Martin Richards
1969 : B language — Ken Thompson ne Unix ke liye banayi
1972 : C language — Dennis Ritchie ne B se develop ki
1973 : Unix OS C mein rewrite hua (pehle assembly mein tha)
1978 : "The C Programming Language" book (K&R) — standard ban gayi
1989 : ANSI C (C89) — official standard
1999 : C99 — inline functions, variable declarations
2011 : C11 — threads, atomics (aaj ka modern C)

Dhyan do: Unix aur C ek doosre ke saath bade. Unix chalane ke liye C bani, aur C ko test karne ke liye Unix kaam aaya. Aaj Linux, macOS sab Unix-based hain — isliye C aaj bhi zinda hai.

Interview question: Q: "C kis language se develop hui?" A: B language se (jo BCPL se bani). Q: "C banane ka reason kya tha?" A: Unix ko assembly se nikal kar ek portable language mein rewrite karna.

C kyun seekhein — features

Practical truth: DSA practice C/C++ mein hi hoti hai, competitive coding ka base bhi yahi hai, aur placements mein pehla coding test aksar C ya C++ mein hota hai.

Tumhara pehla C program

#include <stdio.h>

int main() {
    printf("Hello, DSWallah!\n");
    return 0;
}

Output:
Hello, DSWallah!
gcc hello.c -o hello    # compile (GCC compiler)
./hello                 # run (Linux/Mac)
hello.exe               # run (Windows)

# warnings ke saath strict compile:
gcc -Wall hello.c -o hello
Pro Tip: Pehle din hi gcc ya online compiler (Programiz, OnlineGDB) pe ye program khud type karke chalao. Copy-paste karoge toh galti kabhi nahi dikhegi — typing hi asli seekh hai.

C ka compilation process (4 stages)

Source (hello.c)
   ↓ 1. PREPROCESSOR — #include, #define expand, comments hatao
hello.i (expanded source)
   ↓ 2. COMPILER — C code → assembly code (syntax errors yahin)
hello.s (assembly)
   ↓ 3. ASSEMBLER — assembly → machine code (object file)
hello.o (object)
   ↓ 4. LINKER — library functions (printf) join + main jodo
hello (executable)

Ek command mein sab: gcc hello.c -o hello

Ye 4 stages har exam mein poochhi jaati hain: preprocessor → compiler → assembler → linker. Linker ka kaam samjho — tumne printf nahi likha, wo stdio library mein pada hai; linker use tumhare program se jodta hai.

Common confusion: Compilation error tab aata hai jab program compile ho raha ho (syntax galat), runtime error jab program chal raha ho (jaise divide by zero). Dono alag hain — interview mein poochha jaata hai.

Exercise

Question: C language kisne banayi? (poora naam, space se likho)

Question: C language kis saal bani? Sirf number daalo.

Question: C program ka entry point (shuruaat wala function) ka naam kya hai?

Question: Compilation ki pehli stage ka naam kya hai? (preprocessor / compiler / linker)

Common mistakes

Desi example: Aata se roti — compilation ka desi analogy

Ghar pe roti banne ka poora process compilation jaisa hai — har stage ek kaam karti hai, aur koi stage chhodi toh roti plate pe nahi aayegi:

text
Aata (source)   → preprocessor: chaan-na, ready karna
Belna (compile) → code ko shape dena (assembly)
Secna (assemble)→ machine code banao
Serve (link)    → plate pe jodo (libraries)
Roti (output)   → program chal gaya!
Exam mapping (TCS / College / GATE)
  • TCS NQT: "Who developed C?" — Dennis Ritchie, 1972, Bell Labs.
  • College exam: Hello World program likhwana + header file ka kaam poochha jaata hai.
  • GATE: 4 stages of compilation ka order — preprocessor → compiler → assembler → linker.
  • Trap: "#include ek function hai" — galat, wo preprocessor directive hai.
Lesson complete?

C ka introduction clear. Agla lesson — Variables & Data Types — mein dekhenge data store kaise karte hain aur kitne type ke variables hote hain.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course