Keywords vs Identifiers
💻 Keywords & Identifiers in C (Deep but Easy Explanation)
Chalo isko concept + logic + examples ke saath properly samajhte hain 👇
🔹 1. Keywords in C 🔑
Keywords wo words hote hain jo C language me pehle se defined (reserved) hote hain.
Inka meaning fixed hota hai — aap ise change nahi kar sakte.
👉 C language (developed by Dennis Ritchie) me ye words compiler ko instructions dete hain.
✅ Example se samjho
int a = 10;
👉 Yahan:
-
int→ compiler ko batata hai ki variable integer type ka hai -
return→ function ka result batata hai -
if,else→ decision making ke liye
👉 Matlab:
Keywords = Language ke built-in commands 💡
🔹 Total Keywords (32)
auto break case char const continue default do double else enum extern
float for goto if int long register return short signed sizeof static
struct switch typedef union unsigned void volatile while
🔹 Keywords ka kaam (Real Understanding)
| Keyword | Kaam |
|---|---|
int, float, char | Data type batate hain |
if, else, switch | Decision lene ke liye |
for, while, do | Loop chalane ke liye |
return | Function end karne ke liye |
struct, union | Data structure banane ke liye |
❌ Important Rule
👉 Keyword ko kabhi bhi name ke tarah use nahi kar sakte
int int = 5; // ❌ Error
🔹 2. Identifiers in C 🏷️
Identifiers wo naam hote hain jo programmer khud deta hai
👉 Variables, functions, arrays, etc. ke liye
✅ Example
int marks = 90;
👉 Yahan:
-
int→ keyword 🔑 -
marks→ identifier 🏷️ -
90→ constant
👉 Matlab:
Identifiers = Aapke diye hue names 💡
🔹 Real-Life Example 🤔
Socho:
👨🏫 Teacher = Keywords
👨🎓 Students ke naam = Identifiers
👉 Teacher fixed hai
👉 Students ke naam aap rakhte ho
🔹 Rules for Identifiers
✔ Start with letter ya _
✔ Numbers use kar sakte ho (start me nahi)
✔ No space
✔ No special symbols
✔ Keyword nahi hona chahiye
❌ Wrong Identifiers
1marks // number se start ❌
total marks // space ❌
int // keyword ❌
@name // symbol ❌
🔹 Keywords vs Identifiers (Clear Difference)
| Feature | Keywords 🔑 | Identifiers 🏷️ |
|---|---|---|
| Meaning | Predefined | User-defined |
| Control | Language ke paas | Programmer ke paas |
| Count | Fixed (32) | Unlimited |
| Example | int, if | marks, sum |
🔹 One Strong Example 🧠
int total_marks = 100;
👉 Breakdown:
-
int→ keyword -
total_marks→ identifier -
100→ constant
🔹 Final Concept (Very Important)
👉 Keyword = kya karna hai (instruction)
👉 Identifier = kis pe karna hai (name)
🔥 Short Trick to Remember
- Keywords = System ke words
- Identifiers = Aapke words
Comments
Post a Comment