If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Programming में Data Type बहुत ही important concept है। क्योंकि Data Type के according ही हम variable define करते हैं और उनके लिए logic implement करते हैं।
पिछले topic में आपने Variables के बारे में पढ़ा और समझा , आपको याद होगा कि कोई भी variable define करने से पहले हमें उसका type define करते थे जिससे पता लगाया जा सके कि वो variable किस type की value hold करेगा। इस topic में आप उन्ही सब types के बारे में पढ़ेंगे।
Data Type का simply मतलब है किसी variable का type, जिससे हमें पता चल सके कि कोई variable किस type की value hold किये हुए है , या in future किस type की value hold करेगा।
C++ में 5 basic C++ data types define किये गए हैं जो कि इस प्रकार हैं -
Type | Keyword | Description |
---|---|---|
Boolean | bool | Boolean में सिर्फ दो values true , false होती हैं। |
Character | char | यह single character store करता है। |
Integer | int | यह बिना decimal points वाले whole numbers (पूर्ण संख्या) को store करता है। |
Floating point | float | यह fractional numbers को point के बाद 7 digits तक store करता है। |
Double floating point | double | यह भी fractional numbers को point के बाद 15 digits तक store करता है। |
इन्ही basic data types को signed , unsigned , short , long modifiers की help से modify कर सकते हैं , नीचे table variables के types memory size और range के बारें में बताया गया है -
Type | Bit Width | Range |
---|---|---|
char | 1byte | -127 to 127 or 0 to 255 |
unsigned char | 1byte | 0 to 255 |
signed char | 1byte | -127 to 127 |
int | 4bytes | -2147483648 to 2147483647 |
unsigned int | 4bytes | 0 to 4294967295 |
signed int | 4bytes | -2147483648 to 2147483647 |
short int | 2bytes | -32768 to 32767 |
unsigned short int | 2bytes | 0 to 65,535 |
signed short int | 2bytes | -32768 to 32767 |
long int | 8bytes | -2,147,483,648 to 2,147,483,647 |
signed long int | 8bytes | same as long int |
unsigned long int | 8bytes | 0 to 4,294,967,295 |
long long int | 8bytes | -(2^63) to (2^63)-1 |
unsigned long long int | 8bytes | 0 to 18,446,744,073,709,551,615 |
float | 4bytes | |
double | 8bytes | |
long double | 12bytes |
आप किसी भी data type के memory size को sizeof() function की help से check भी कर सकते हैं।
#include <iostream>
using namespace std;
int main() {
cout << "Size of char : " << sizeof(char) << endl;
cout << "Size of int : " << sizeof(int) << endl;
cout << "Size of short int : " << sizeof(short int) << endl;
cout << "Size of long int : " << sizeof(long int) << endl;
cout << "Size of float : " << sizeof(float) << endl;
cout << "Size of double : " << sizeof(double) << endl;
return 0;
}
Size of char : 1 Size of int : 4 Size of short int : 2 Size of long int : 8 Size of float : 4 Size of double : 8
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook