Primitive Data Structures
Primitive Data Structures wo basic data types hote hain jo directly computer memory me store hote hain. Ye simple data ko represent karte hain aur complex data structures ke liye base ka kaam karte hain. Inhe samajhna programming ke liye bahut important hai.
Key Points:
- Sabse simple aur basic data storage types hain.
- Mostly ek hi value ko store karte hain.
- Programming ke building blocks hote hain.
- Memory me direct store hote hain, aur fast access provide karte hain.
- Ye har programming language me available hote hain (C, C++, Java, Python).
1. Integer (int)
Definition: Integer ek poora number hota hai (positive, negative ya zero) jo decimal point ke bina store hota hai.
- Arithmetic operations support karta hai: +, -, *, /
- Memory size: 4 bytes (C/C++ me usually)
- Real-life example: age, marks, number of items, counter, loop iteration
- Signed aur unsigned integers hote hain, signed me negative bhi store hota hai.
int age = 21;
int temperature = -5;
int items = 100;
2. Float (Decimal Numbers / Real Numbers)
Definition: Float ya real number ek number hota hai jo decimal ke sath represent hota hai.
- Fractional numbers ko store karta hai.
- Arithmetic me decimal calculations accurate hote hain.
- Memory size: 4 bytes (C/C++)
- Real-life example: price, weight, height, temperature, GPA
- Float ke comparison thoda tricky ho sakta hai due to precision errors.
float price = 99.99;
float weight = 65.5;
float temperature = 36.6;
3. Character (char)
Definition: Character ek single symbol, alphabet ya number ko represent karta hai.
- Sirf ek character store karta hai.
- ASCII ya Unicode ke through memory me store hota hai.
- Memory size: 1 byte.
- Real-life example: initial of name, grade symbol, keyboard input, single letter variables.
- Character ko integer me convert karke ASCII value se bhi use kar sakte hain.
char grade = 'A';
char initial = 'N';
char symbol = '#';
4. Boolean (bool)
Definition: Boolean sirf true ya false value store karta hai.
- Logic aur decision making me use hota hai.
- Conditional statements me kaam aata hai (if, while, for loops)
- Memory size: 1 byte (language dependent)
- Real-life example: login status, switch on/off, flag variables
- Boolean ka use program ke flow control me bahut important hai.
bool isStudent = true;
bool isLoggedIn = false;
5. String (Array of Characters)
Definition: String ek sequence of characters hoti hai, usually text ko store karne ke liye.
- Characters ka continuous sequence hota hai.
- Null character (\0) se string ke end ko define kiya jata hai (C/C++ me)
- Length variable ya fixed ho sakti hai.
- Real-life example: name, city, message, email, password
- Strings me concatenation, comparison, substring extraction hota hai.
char name[] = "Nitesh";
char city[] = "Indore";
char message[] = "Hello World";
Quick Summary Table
| Data Type | Kya Store Karta Hai | Example | Memory Size | Additional Notes |
|---|---|---|---|---|
| Integer | Poore numbers (decimal ke bina) | 10, -5, 0 | 4 bytes | Signed aur unsigned integers |
| Float | Decimal numbers / fractional values | 5.5, 99.99 | 4 bytes | Precision thodi tricky ho sakti hai |
| Character | Single alphabet / symbol / number | 'A', '#', '5' | 1 byte | ASCII / Unicode ke through stored |
| Boolean | True / False | true, false | 1 byte | Logic / Decision making ke liye |
| String | Sequence of characters (text) | "Hello", "Nitesh" | Variable | Concatenation, substring, comparison possible |
Tips for Exams & Programming
- Ye sab programming ke base types hain, inhe strong yaad karo.
- Operations har type ke liye alag hote hain: arithmetic, logic, comparison, concatenation.
- Ye types directly memory me store hote hain aur complex structures ka base hote hain.
- Real-life examples ke sath yaad karne se yaad rakhna easy ho jata hai.
- Exam ke liye table aur examples ko revise karna bahut important hai.
Comments
Post a Comment