C Programming में Keywords क्या होते हैं? उदाहरण सहित पूरी जानकारी | Keywords in C Programming with Examples

Keywords in C programming with examples से समझना हर नए programmer के लिए बेहद ज़रूरी है, क्योंकि ये बुनियादी Word हैं जिनके बिना C language में एक भी meaningful program नहीं लिखा जा सकता। जब आप पहली बार C सीखना शुरू करते हैं, तो सबसे पहले आपका सामना इन्हीं reserved words से होता है, जैसे int, if, while, return — और इन्हें सही तरीके से जानना आपकी coding journey को मज़बूत नींव पर खड़ा करता है।

इस blog post में हम C language के सभी 32 keywords को विस्तार से समझेंगे, उनकी categories जानेंगे, और हर important keyword के real code examples देखेंगे। साथ ही यह भी जानेंगे कि keywords और identifiers में क्या फर्क है, और programming करते समय किन common गलतियों से बचना चाहिए।

चाहे आप किसी university exam की तैयारी कर रहे हों, किसी interview के लिए C revise कर रहे हों, या बिल्कुल scratch से C programming सीख रहे हों — यह guide आपके लिए एक complete reference की तरह काम करेगी। अंत तक पढ़ें और C keywords पर अपनी पकड़ पक्की करें।

C Programming में Keywords क्या होते हैं?

Keywords in C programming वो predefined, reserved words होते हैं जिनका अर्थ compiler के लिए पहले से तय होता है। इन्हें आप variable name, function name या किसी भी identifier के रूप में use नहीं कर सकते। C language में कुल 32 keywords होते हैं, जो ANSI C standard के अनुसार define किए गए हैं।

सरल भाषा में कहें तो — जैसे Hindi भाषा में कुछ शब्दों का अपना fixed meaning होता है, वैसे ही C compiler के लिए इन keywords का meaning fixed होता है। अगर आपने int नाम का variable बनाने की कोशिश की, तो compiler error देगा, क्योंकि int एक reserved keyword है।

Keywords की मुख्य विशेषताएं

  • ये हमेशा lowercase में लिखे जाते हैं।
  • इन्हें variable, function या array के नाम के रूप में use नहीं किया जा सकता।
  • हर keyword का compiler के लिए एक specific purpose होता है।
  • ये C language की syntax और structure का हिस्सा हैं।

C के सभी 32 Keywords की सूची

नीचे ANSI C के सभी 32 keywords दिए गए हैं:

Data TypesControl FlowStorage ClassOthers
intifautoreturn
floatelseregistersizeof
doubleswitchstatictypedef
charcaseexternstruct
voidforunion
shortwhileenum
longdoconst
signedbreakvolatile
unsignedcontinue
goto
default
keywords in c programming with examples

Categories के अनुसार Keywords in C Programming with Examples

1. Data Type Keywords

ये keywords variables के data type को define करते हैं — यानी बताते हैं कि variable में किस प्रकार का data store होगा।

int — Integer Data Type

Integer Data Type Program Code:
#include <stdio.h>

int main() {
    int age = 21;   // Store age

    printf("Age: %d\n", age);

    return 0;
}
▶️ Output Result
Age: 21

int keyword पूर्णांक (whole number) values store करने के लिए use होता है।

float और double — Decimal Numbers

Float Data Type Program Code:
#include <stdio.h>

int main() {
    float price = 99.99f;            // Floating-point value
    double pi = 3.14159265358979;    // Double-precision floating-point value

    printf("Price: %.2f\n", price);
    printf("Pi: %lf\n", pi);

    return 0;
}
▶️ Output Result
Price: 99.99 Pi: 3.141593

char — Character Data Type

Char Data Type Program Code:
#include <stdio.h>

int main() {
    char grade = 'A';   // Store a character

    printf("Grade: %c\n", grade);

    return 0;
}
▶️ Output Result
Grade: A

void — No Value

void keyword का use तब होता है जब function कोई value return नहीं करता।

Void Data type Program Code:
#include <stdio.h>

// Function to display a greeting message
void greet() {
    printf("Good Morning, C Programmer!\n");
}

int main() {
    // Call the function
    greet();

    return 0;
}
▶️ Output Result
Good Morning, C Programmer!

2. Control Flow Keywords

ये keywords program के execution flow को control करते हैं।

if, else — Conditional Statements

If else Program Code:
#include <stdio.h>

int main() {
    int marks = 75;   // Store the student's marks

    // Check whether the student has passed or failed
    if (marks >= 60) {
        printf("Pass\n");
    } else {
        printf("Fail\n");
    }

    return 0;
}
▶️ Output Result
Pass

switch, case, default — Multiple Conditions

Switch case Program Code:
#include <stdio.h>

int main() {
    int day = 2;   // Store the day number

    // Display the day name based on the day number
    switch (day) {
        case 1:
            printf("Monday\n");
            break;

        case 2:
            printf("Tuesday\n");
            break;

        default:
            printf("Some other day\n");
    }

    return 0;
}
▶️ Output Result
Tuesday

for Loop — Counted Repetition

For Loop Program Code:
#include <stdio.h>

int main() {
    // Print numbers from 1 to 5
    for (int i = 1; i <= 5; i++) {
        printf("Count: %d\n", i);
    }

    return 0;
}
▶️ Output Result
Count: 1 Count: 2 Count: 3 Count: 4 Count: 5

while और do-while — Condition-Based Loops

While Program Code:
#include <stdio.h>

int main() {
    int n = 1;   // Initialize the while loop counter

    // While loop
    while (n <= 3) {
        printf("n = %d\n", n);
        n++;
    }

    // Do-while loop
    int x = 0;

    do {
        printf("do-while: x = %d\n", x);
        x++;
    } while (x < 3);

    return 0;
}
▶️ Output Result
n = 1 n = 2 n = 3 do-while: x = 0 do-while: x = 1 do-while: x = 2

break और continue

Break And Continue Program Code:
#include <stdio.h>

int main() {
    // Loop from 0 to 9
    for (int i = 0; i < 10; i++) {

        // Exit the loop when i becomes 5
        if (i == 5) {
            break;
        }

        // Skip the value 3
        if (i == 3) {
            continue;
        }

        printf("%d ", i);
    }

    return 0;
}
▶️ Output Result
0 1 2 4

goto — Unconditional Jump

Goto Statement Program Code:
#include <stdio.h>

int main() {
    int i = 0;   // Initialize the counter

start:
    // Print the current value of i
    printf("%d\n", i);

    i++;

    // Jump back to the label while i is less than 3
    if (i < 3) {
        goto start;
    }

    return 0;
}
▶️ Output Result
0 1 2

Note: goto का use आजकल avoid किया जाता है क्योंकि इससे code पढ़ना कठिन हो जाता है।

3. Storage Class Keywords

ये keywords बताते हैं कि variable कहाँ और कितने समय तक store रहेगा।

auto — यह default storage class है। Local variables automatically auto होते हैं।

static — Variable की value function call के बाद भी बनी रहती है।

Static Variable Program Code:

#include <stdio.h>

// Function with a static variable
void counter() {
    static int count = 0;   // Retains its value between function calls

    count++;

    printf("Count: %d\n", count);
}

int main() {
    // Call the function three times
    counter();
    counter();
    counter();

    return 0;
}
▶️ Output Result
Count: 1 Count: 2 Count: 3

extern — दूसरी file में define हुए variable को access करने के लिए।

register — Variable को CPU register में store करने की request करता है, जिससे access तेज़ होती है।

register int i;

for(i = 0; i < 1000000; i++) { /* fast loop */ }

4. Other Important Keywords

return — Value वापस करना

int add(int a, int b) {

return a + b;  // result return karo

}

sizeof — किसी Data type या function का Size जानना

sizeof() Program Code:
#include <stdio.h>

int main() {
    // Display the size of different data types
    printf("Size of int: %zu bytes\n", sizeof(int));
    printf("Size of float: %zu bytes\n", sizeof(float));
    printf("Size of char: %zu bytes\n", sizeof(char));

    return 0;
}
▶️ Output Result
Size of int: 4 bytes Size of float: 4 bytes Size of char: 1 bytes

struct — User-defined Data Type

Struct Data Type Program Code:
#include <stdio.h>

// Structure to store student information
struct Student {
    char name[50];   // Student name
    int roll;        // Roll number
    float marks;     // Marks
};

int main() {
    // Initialize a structure variable
    struct Student s1 = {"Rahul", 101, 89.5f};

    printf("Name: %s\n", s1.name);
    printf("Roll Number: %d\n", s1.roll);

    return 0;
}
▶️ Output Result
Name: Rahul Roll Number: 101

typedef — नया नाम देना

typedef unsigned long int ULONG;

ULONG bigNumber = 4000000000;

const — Value को Lock करना

const float PI = 3.14;

// PI = 3.15;  // Error! const variable change nahi hota

enum — Named Integer Constants

Enum Data Type Program Code:
#include <stdio.h>

// Enumeration for seasons
enum Season {
    Spring,
    Summer,
    Autumn,
    Winter
};

int main() {
    // Assign an enum value
    enum Season s = Summer;

    printf("Season value: %d\n", s);

    return 0;
}
▶️ Output Result
Season value: 1

Keywords Vs Identifiers — क्या फर्क है?

यह एक बहुत common confusion है। Keywords predefined होते हैं और compiler इन्हें पहचानता है, जबकि identifiers वो names हैं जो programmer खुद define करता है (जैसे variable names, function names)।

KeywordsIdentifiers
Predefined होते हैंProgrammer define करता है
Lowercase में होते हैंUpper/lowercase दोनों हो सकते हैं
Meaning fixed हैMeaning programmer तय करता है
Example: int, forExample: myAge, calculateSum

सबसे ज़रूरी नियम: Identifier को keyword के नाम पर नहीं बनाया जा सकता।

int float = 5;   //  Error — float एक keyword है

int myFloat = 5; //  Correct

Common Mistakes जो Beginners करते हैं

1. Keywords को Capital Letters में लिखना

Int age = 20;   //  Error

int age = 20;   //  Correct

2. Keyword को Variable Name बनाना

int return = 10;  //  Error

int result = 10;  //  Correct

3. break को Loop के बाहर Use करना

int main() {

break;  //  Error — loop या switch के बाहर break नहीं चलता

return 0;

}

 Conclusion ( निष्कर्ष )

Keywords in C programming with examples को समझ लेना आपकी C programming की नींव को पूरी तरह मज़बूत कर देता है। इस पूरे blog में हमने 32 keywords की categories, उनके real code examples, keywords और identifiers का फर्क, और common mistakes — सब कुछ विस्तार से cover किया। अब आप जानते हैं कि static variable क्यों अपनी value याद रखता है, const क्यों lock होता है, और volatile embedded systems में क्यों ज़रूरी है।

अगर आप सच में C programming में expert बनना चाहते हैं, तो सिर्फ पढ़ने से काम नहीं चलेगा — हर keyword का code खुद type करें, experiment करें, और errors से सीखें। इस article को bookmark करें ताकि future में reference के तौर पर काम आए, और नीचे comment करके बताएं कि कौन सा keyword आपको सबसे confusing लगा। अपने coding दोस्तों के साथ share ज़रूर करें!

Frequently Asked Questions

Q 1: C programming में कुल कितने keywords होते हैं?
Ans: ANSI C (C89/C90) standard के अनुसार C में 32 keywords होते हैं। C99 standard में 5 नए keywords जोड़े गए जैसे _Bool, _Complex, _Imaginary, inline, और restrict, जिससे कुल 37 हो जाते हैं।
Q 2: क्या keywords को variable name के रूप में use किया जा सकता है?
Ans: नहीं, बिल्कुल नहीं। Keywords C compiler के लिए reserved होते हैं। अगर आप int, for, या किसी भी keyword को variable name की तरह use करेंगे, तो compiler compilation error देगा।
Q 3: Keywords हमेशा lowercase में क्यों होते हैं?
Ans: C एक case-sensitive language है। int और Int दो अलग चीज़ें हैं — int एक keyword है जबकि Int एक valid identifier हो सकता है। यह convention C language के शुरुआत से ही follow किया जाता है।
Q 4: auto keyword का क्या use है, क्या यह C++ के auto जैसा है?
Ans: नहीं। C में auto का मतलब है local variable की automatic storage class, जो default होती है और इसलिए rarely लिखी जाती है। C++ में auto type-inference के लिए use होता है — दोनों बिल्कुल अलग concepts हैं।
Q 5: volatile keyword क्या करता है?
Ans: volatile keyword compiler को बताता है कि इस variable की value कभी भी बदल सकती है — जैसे hardware register, interrupt service routine में। इससे compiler उस variable को cache नहीं करता और हर बार memory से ताज़ा value पढ़ता है। यह embedded systems programming में बहुत ज़रूरी है।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top