Data Type in C in Hindi – Complete Guide with Examples (हिंदी)

आज आप इस Post में पढ़ने वाले हैं Data Type in C in Hindi में Detailed explanation और real code examples के साथ। C programming सीखते समय सबसे पहला और सबसे जरूरी concept जो आपको समझना होता है वह है Data Types — क्योंकि बिना data types को समझे आप एक भी सही program नहीं लिख सकते। हर variable जो आप declare करते हैं, हर value जो आप store करते हैं — उसके पीछे data type का concept काम करता है।

इस blog post में हम data types को बिल्कुल शुरुआत से सीखेंगे। आपको किसी advanced knowledge की जरूरत नहीं है — बस यह जानना काफी है कि C programming क्या होती है। हम सरल हिंदी भाषा में, step-by-step explanation और working code examples के साथ इस पूरे topic को cover करेंगे। हर data type को practically समझाया जाएगा ताकि आपको real programs में इसे use करने में कोई दिक्कत न हो।

इस post को पढ़ने के बाद आप जानेंगे कि Data Type in C क्या होता है, यह क्यों जरूरी है, कितने प्रकार के data types होते हैं, हर data type की size और range क्या होती है, format specifiers कैसे use होते हैं, और real programs में इन्हें कैसे apply किया जाता है। तो चलिए शुरू करते हैं!

Data Type in C क्या होता है?

Data Type in C एक ऐसा keyword होता है जो compiler को यह बताता है कि किसी variable में किस तरह का data store होगा और उस data के लिए कितनी memory allocate करनी होगी। सरल भाषा में कहें तो — जब आप कोई variable बनाते हैं, तो आपको पहले यह तय करना होता है कि उसमें कौन से type की value रखी जाएगी — कोई पूरा number (integer), कोई decimal number (float), कोई अक्षर (character), या कोई और value।

उदाहरण के लिए:

  • अगर आप किसी की उम्र store करना चाहते हैं → int use करेंगे
  • अगर आप किसी की salary store करना चाहते हैं → float use करेंगे
  • अगर आप किसी Student का grade store करना चाहते हैं → char use करेंगे

यही data type का मूल concept है — सही data के लिए सही type चुनना।

Data Type in C क्यों जरूरी है?

Data types निम्नलिखित कारणों से बेहद जरूरी हैं:

Memory Management: हर data type के लिए अलग-अलग memory allocate होती है। int के लिए 4 bytes, char के लिए 1 byte — यह compiler को पता होता है सिर्फ data type की वजह से।

Data Accuracy: सही data type use करने से calculations सही होती हैं। जैसे अगर आप decimal numbers को int में store करेंगे तो decimal part खो जाएगा।

Type Safety: C compiler data type check करता है और गलत operations पर error या warning देता है — जिससे program में bugs कम होते हैं।

Performance Optimization: छोटे data types (जैसे char, short) बड़े data types से कम memory use करते हैं, जो embedded systems में बहुत फर्क डालते हैं।

Data Types के प्रकार (Types of Data Types in C)

C language में data types को मुख्यतः तीन categories में बाँटा जाता है:

  • Primary (Fundamental) Data Types
  • Derived Data Types
  • User-Defined Data Types

आइए इन्हें एक-एक करके विस्तार से समझते हैं।

1. Primary Data Types in C Programming

Primary data types वे basic building blocks हैं जो C language में पहले से defined होते हैं। इन्हें किसी और चीज़ से बनाया नहीं जाता — ये खुद ही fundamental होते हैं।

C Programming में चार primary data types होते हैं:

  • intInteger (पूर्ण संख्याएं)
  • floatFloating-point (दशमलव संख्याएं)
  • doubleDouble precision floating-point
  • charCharacter (अक्षर या symbol)

int Data Type (Integer)

int data type का use पूर्ण संख्याओं (whole numbers) को store करने के लिए होता है — जैसे age, roll number, marks आदि।

Size: 4 bytes (32-bit system पर)
Range: -2,147,483,648 से 2,147,483,647
Format Specifier: %d

Program Code:
#include <stdio.h>

int main() {
    int age = 20;          // Store age
    int marks = 95;        // Store marks
    int temperature = -5;  // Integer can also store negative values

    printf("Age: %d\n", age);
    printf("Marks: %d\n", marks);
    printf("Temperature: %d\n", temperature);

    return 0;
}
▶️ Output Result
Age: 20 Marks: 95 Temperature: -5

int के Modifiers: C में int के साथ modifiers use करके range और behavior बदला जा सकता है:

  • short int2 bytes, range: -32,768 से 32,767
  • long int4 या 8 bytes, बड़ी संख्याओं के लिए
  • unsigned int — केवल positive values, 0 से 4,294,967,295
  •  signed int — positive और negative दोनों (default)
Program Code:
#include <stdio.h>

int main() {
    short int s = 30000;          // Short integer
    long int l = 1234567890;      // Long integer
    unsigned int u = 4000000000U; // Unsigned integer

    printf("Short int: %d\n", s);
    printf("Long int: %ld\n", l);
    printf("Unsigned int: %u\n", u);

    return 0;
}
▶️ Output Result
Short int: 30000 Long int: 1234567890 Unsigned int: 4000000000

float Data Type (Floating-Point)

float data type का use decimal numbers (दशमलव संख्याओं) को store करने के लिए होता है — जैसे price, weight, percentage आदि।

Size: 4 bytes
Precision: लगभग 6-7 decimal digits
Format Specifier: %f

Program Code:
#include <stdio.h>

int main() {
    float price = 199.99f;    // Price value
    float weight = 65.5f;     // Weight value
    float pi = 3.14159f;      // Value of Pi

    printf("Price: %.2f\n", price);
    printf("Weight: %.1f\n", weight);
    printf("Pi value: %.5f\n", pi);

    return 0;
}
▶️ Output Result
Price: 199.99 Weight: 65.5 Pi value: 3.14159

double Data Type

double data type भी decimal numbers store करने के लिए होता है, लेकिन float से ज्यादा precision के साथ। Scientific calculations में इसका use होता है।

Size: 8 bytes
Precision: लगभग 15-16 decimal digits
Format Specifier: %lf

Program Code:
#include <stdio.h>

int main() {
    double exactPi = 3.14159265358979;          // Double-precision floating-point value
    double bigNumber = 1234567890.123456789;    // Large decimal number

    printf("Exact Pi: %.14lf\n", exactPi);
    printf("Big Number: %.9lf\n", bigNumber);

    return 0;
}
▶️ Output Result
Exact Pi: 3.14159265358979 Big Number: 1234567890.123456717

float और double में यही फर्क है — double ज्यादा accurate होता है। जब आपको high precision चाहिए (जैसे scientific या financial calculations में), तो double use करें।

char Data Type (Character)

char data type एक single character store करता है — जैसे कोई अक्षर, digit, या symbol C में characters को single quotes ‘ ‘ में लिखा जाता है।

Size: 1 byte
Range: -128 से 127 (signed) या 0 से 255 (unsigned)
Format Specifier: %c

Program Code:
#include <stdio.h>

int main() {
    char grade = 'A';    // Character variable
    char symbol = '#';   // Special symbol
    char digit = '5';    // Character representing a digit

    printf("Grade: %c\n", grade);
    printf("Symbol: %c\n", symbol);
    printf("Digit character: %c\n", digit);

    // Display the ASCII value of a character
    printf("ASCII value of '%c': %d\n", grade, grade);

    return 0;
}
▶️ Output Result
Grade: A Symbol: # Digit character: 5 ASCII value of ‘A’: 65

Important बात: C में char और int बहुत closely related हैं क्योंकि हर character की एक integer ASCII value होती है। ‘A’ = 65, ‘a’ = 97, ‘0’ = 48 — यह याद रखें।

2. Derived Data Types in C

Derived data types वे होते हैं जो primary data types से मिलकर बने होते हैं। इनमें शामिल हैं:

1. Array

Array एक ही type के multiple values को एक साथ store करता है।

Program Code:
#include <stdio.h>

int main() {
    int marks[5] = {85, 90, 78, 92, 88};   // Array of 5 integer values

    // Display all array elements
    for (int i = 0; i < 5; i++) {
        printf("marks[%d] = %d\n", i, marks[i]);
    }

    return 0;
}
▶️ Output Result
marks[0] = 85 marks[1] = 90 marks[2] = 78 marks[3] = 92 marks[4] = 88

2. Pointer

Pointer एक variable होता है जो किसी दूसरे variable के memory address store करता है।

Program Code:
#include <stdio.h>

int main() {
    int num = 42;       // Integer variable
    int *ptr = &num  ;  // Pointer storing the address of num

    printf("Value: %d\n", num);
    printf("Address: %p\n", ptr);
    printf("Value using pointer: %d\n", *ptr);

    return 0;
}
▶️ Output Result
Value: 42 Address: 0x7ff… Value using pointer: 42

3. Function In C

Functions भी derived data types का हिस्सा हैं — वे एक specific data type return करते हैं।

3. User-Defined Data Types in C

User-defined data types वे होते हैं जिन्हें programmer खुद define करते हैं। इनमें शामिल हैं:

1. Structure (struct)

Structure में अलग-अलग data types के variables को एक साथ group किया जाता है।

Program Code:
#include <stdio.h>

// Structure definition
struct Student {
    char name[50];      // Student name
    int age;            // Student age
    float percentage;   // Student percentage
};

int main() {
    struct Student s1;   // Structure variable

    // Assign values to structure members
    s1.age = 18;
    s1.percentage = 92.5f;

    printf("Age: %d\n", s1.age);
    printf("Percentage: %.2f\n", s1.percentage);

    return 0;
}
▶️ Output Result
Age: 18 Percentage: 92.50

2. Union In C Language

Union structure जैसा ही होता है, लेकिन इसमें सभी members एक ही memory location share करते हैं।

3. Enum (Enumeration)

Enum user-defined integer constants का set होता है।

Program Code:
#include <stdio.h>

// Enumeration for days of the week
enum Days {
    Monday = 1,
    Tuesday,
    Wednesday,
    Thursday,
    Friday
};

int main() {
    enum Days today = Wednesday;   // Assign Wednesday to the variable

    printf("Day number: %d\n", today);

    return 0;
}
▶️ Output Result
Day number: 3
Data Type in C in Hindi

void Data Type — एक Special Type

void एक special data type है जिसका अर्थ होता है “कोई value नहीं।” इसके तीन main uses हैं:

Function return type: जब function कोई value return न करे।

    void printMessage() {

	printf("Hello, World!\n");

	// कोई return statement नहीं
}

Function parameters: जब function कोई argument न ले।

int getNumber(void) {
	return 42;
}

Void pointer: किसी भी type का address store करने के लिए।

void *ptr;   // Generic pointer

C Data Types — Size, Range और System Architecture (32-bit) 

C language में data types यह decide करते हैं कि किसी variable में किस प्रकार का data store होगा और memory में कितनी जगह लेगा। हर data type की एक fixed size (bytes में) और एक range होती है जो बताती है कि उसमें minimum और maximum कितनी value store हो सकती है। सही data type चुनना memory efficient program लिखने के लिए बहुत जरूरी है। 

Data TypeSizeRangeFormat Specifier
char1 byte-128 से 127%c / %hhd
unsigned char1 byte0 से 255%c / %hhu
short int2 bytes-32,768 से 32,767%hd
int4 bytes-2,147,483,648 से 2,147,483,647%d
unsigned int4 bytes0 से 4,294,967,295%u
long int4 bytes-2,147,483,648 से 2,147,483,647%ld
unsigned long int4 bytes0 से 4,294,967,295%lu
float4 bytes1.2E-38 से 3.4E+38%f
double8 bytes2.3E-308 से 1.7E+308%lf

sizeof() Operator — Data Type की Size कैसे पता करें?

C में sizeof() operator किसी भी data type या variable की memory size (bytes में) बताता है। यह बेहद useful होता है, खासकर जब हमें किसी data type का Size पता न हो और हमें उस data type का size जानना हो। निचे दिए गए program से समझ सकते हैं। 

Program Code:

#include <stdio.h>

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

    return 0;
}
▶️ Output Result
Size of char: 1 bytes Size of int: 4 bytes Size of short int: 2 bytes Size of long int: 4 bytes Size of float: 4 bytes Size of double: 8 bytes Size of long double: 12 bytes

Note: Memory Size को print करने के लिए %ZU Format Spcifier का use करते हैं।

Practical Example Program — सभी Data Types एक साथ

यह एक complete program है जो Data Type in C के सभी primary types को एक साथ demonstrate करता है — एक student record system के रूप में।

Program Code:

#include <stdio.h>

int main() {
    // Student information stored using different data types
    int rollNumber = 101;
    char grade = 'A';
    float percentage = 88.75f;
    double totalScore = 1234567.89123456;
    short int age = 19;
    unsigned int attendance = 245;

    printf("====== Student Record ======\n");
    printf("Roll Number : %d\n", rollNumber);
    printf("Age         : %d\n", age);
    printf("Grade       : %c\n", grade);
    printf("Percentage  : %.2f%%\n", percentage);
    printf("Total Score : %.8lf\n", totalScore);
    printf("Attendance  : %u days\n", attendance);

    printf("\n====== Memory Sizes ======\n");
    printf("int    : %zu bytes\n", sizeof(rollNumber));
    printf("char   : %zu bytes\n", sizeof(grade));
    printf("float  : %zu bytes\n", sizeof(percentage));
    printf("double : %zu bytes\n", sizeof(totalScore));

    return 0;
}
▶️ Output Result
====== Student Record ====== Roll Number : 101 Age : 19 Grade : A Percentage : 88.75% Total Score : 1234567.89123456 Attendance : 245 days====== Memory Sizes ====== int : 4 bytes char : 1 bytes float : 4 bytes double : 8 bytes

Conclusion (निष्कर्ष )

आज आपने Data Type in C in Hindi में एक दम details में समझा। इस post में हमने देखा कि Primary Data Types (int, float, double, char) कैसे काम करते हैं, Derived और User-Defined Data Types क्या होते हैं, sizeof() operator कैसे use करते हैं, और format specifiers का सही उपयोग क्या है।

एक अच्छे programmer की पहचान यही है कि वह हर situation में सही data type चुने — न ज्यादा memory waste करे, न कम। अगर आप इन concepts को अच्छे से समझ लेते हैं, तो आगे के topics जैसे Arrays, Pointers और Structures सीखना बहुत आसान हो जाता है।

Practice ही सबसे बड़ा teacher है — ऊपर दिए गए सभी code examples को खुद run करें, output देखें, और values बदलकर experiment करें। यही तरीका है C programming में expert बनने का।

Frequently Asked Questions

Q 1: Data Type in C क्या होता है और यह क्यों जरूरी है?
Ans: Data Type compiler को बताता है कि variable में किस तरह का data store होगा और कितनी memory चाहिए। इससे सही memory allocation, data accuracy, और type-checking होती है — जिससे bugs कम होते हैं और program efficient बनता है।
Q 2: C में कितने प्रकार के Data Types होते हैं?
Ans: तीन categories होती हैं —
  • Primary (int, float, double, char)
  • Derived (Array, Pointer, Function)
  • User-Defined (struct, Union, Enum)
  • Beginners को पहले Primary Data Types सीखने चाहिए।
    Q 3: int और float में क्या अंतर है?
    Ans: int सिर्फ पूर्ण संख्याएं store करता है (जैसे 5, -20), जबकि float दशमलव संख्याएं store करता है (जैसे 3.14, 99.99)। दोनों 4 bytes लेते हैं।
    Q 4: sizeof() operator क्या करता है?
    Ans: यह किसी data type की memory size bytes में बताता है। जैसे sizeof(int) = 4 bytes, sizeof(char) = 1 byte। Memory-sensitive programs में यह बहुत उपयोगी होता है।
    Q 5: float literal में ‘f’ suffix क्यों लगाते हैं?
    Ans: C में decimal numbers by default double type के होते हैं। f suffix लगाने से compiler को पता चलता है कि यह float है — जिससे precision loss और warning से बचा जा सकता है। जैसे: float price = 99.99f;

    Leave a Comment

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

    Scroll to Top