C++ Data Types In Hindi

📔 : C++ 🔗

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++ Primitive Built-in Data Types

C++ में 5 basic C++ data types define किये गए हैं जो कि इस प्रकार हैं -

TypeKeywordDescription
BooleanboolBoolean में सिर्फ दो values true , false होती हैं।
Charactercharयह single character store करता है।
Integerintयह बिना decimal points वाले whole numbers (पूर्ण संख्या) को store करता है।
Floating pointfloatयह fractional numbers को point के बाद 7 digits तक store करता है।
Double floating pointdoubleयह भी fractional numbers को point के बाद 15 digits तक store करता है।

इन्ही basic data types को signed , unsigned , short , long modifiers की help से modify कर सकते हैं , नीचे table variables के types memory size और range के बारें में बताया गया है -

TypeBit WidthRange
char1byte-127 to 127 or 0 to 255
unsigned char1byte0 to 255
signed char1byte-127 to 127
int4bytes-2147483648 to 2147483647
unsigned int4bytes0 to 4294967295
signed int4bytes-2147483648 to 2147483647
short int2bytes-32768 to 32767
unsigned short int2bytes0 to 65,535
signed short int2bytes-32768 to 32767
long int8bytes-2,147,483,648 to 2,147,483,647
signed long int8bytessame as long int
unsigned long int8bytes0 to 4,294,967,295
long long int8bytes-(2^63) to (2^63)-1
unsigned long long int8bytes0 to 18,446,744,073,709,551,615
float4bytes
double8bytes
long double12bytes

C++ sizeof()

आप किसी भी data type के memory size को sizeof() function की help से check भी कर सकते हैं।

CopyFullscreenClose FullscreenRun
#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;
}
Output
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

Related Topics :

Rahul Kumar

Rahul Kumar

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

b2eprogrammers