आपकी ऑफलाइन सहायता

BACK
49

सी प्रोग्रामिंग

149

पाइथन प्रोग्रामिंग

49

सी प्लस प्लस

99

जावा प्रोग्रामिंग

149

जावास्क्रिप्ट

49

एंगुलर जे.एस.

69

पी.एच.पी.
माय एस.क्यू.एल.

99

एस.क्यू.एल.

Free

एच.टी.एम.एल.

99

सी.एस.एस.

149

आर प्रोग्रामिंग

39

जे.एस.पी.





डाउनलोड पी.डी.एफ. ई-बुक्स
C - Data Types
C Programming में दो प्रकार के Data Types होते है |
  1. Basic Data Types
  2. Derived Data Types

Basic Data Types Derived Data Types
  1. int (Integer)
  2. char (Character)
  3. float
  4. double
  5. void
  1. Arrays
  2. Pointers
  3. Structure
  4. Unions
  5. Enums (Enumerations)

Basic Data Types
1. int (Integer)
  • Integer Data Type में variable को declare करने के 'int' keyword का इस्तेमाल करते है |
  • Integer Data Type सभी numeric values को store कर सकता है |
  • integer को output में print करना हो तो '%d' format specifier से output में print करते है |
  • Integer Data Type 2, 4 और 8 bytes के हो सकते है |
  • अगर Computer का Processor 16-bit हो तो int का size 2 Bytes होता है |
  • अगर Computer का Processor 32-bit हो तो int का size 4 Bytes होता है |
  • अगर Computer का Processor 64-bit हो तो int का size 8 Bytes होता है |

Integer Data Types, Storage Size and Range

Data TypesStorage SizeRange
int (16-bit)2 Bytes-32,768 to 32,767
int (32-bit)4 Bytes-2,147,483,648 to 2,147,483,647
int (64-bit)8 Bytes-9,223,372,036,854,775,807 to 9,223,372,036,854,775,807
unsigned int (16-bit)2 Bytes0 to 65,535
short int2 Bytes-32,768 to 32,767
unsigned short int2 Bytes0 to 65,535
signed short int2 Bytes–32,768 to 32,767
long int4 Bytes–2,147,483,647 to 2,147,483,647
unsigned long int4 Bytes0 to 4,294,967,295
signed long int4 Bytes–2,147,483,648 to 2,147,483,647

sizeof इस keyword से int Data Types के size का पता करे |
Source Code :
#include <stdio.h>

int main() {
printf("int(16-bit) storage size : %d \n", sizeof(int));
printf("int(32-bit) storage size : %d \n", sizeof(int));
printf("int(64-bit) storage size : %d \n", sizeof(int));
printf("unsigned int storage size : %d \n", sizeof(unsigned int));
printf("short int storage size : %d \n", sizeof(short int));
printf("unsigned short int storage size : %d \n", sizeof(unsigned short int));
printf("signed short int storage size : %d \n", sizeof(signed short int));
printf("long int storage size : %d \n", sizeof(long int));
printf("unsigned long int storage size : %d \n", sizeof(unsigned long int));
printf("signed long int storage size : %d \n", sizeof(signed long int));
return 0;
}

Output

int(16-bit) storage size : 2
int(32-bit) storage size : 4
int(64-bit) storage size : 8
unsigned int storage size : 4
short int storage size : 2
unsigned short int storage size : 2
signed short int storage size : 2
long int storage size : 4
unsigned long int storage size : 4
signed long int storage size : 4

2. char (Character)
  • Character Data Type में variable को declare करने के 'char' keyword का इस्तेमाल करते है |
  • Character को output में print करना हो तो '%c' format specifier से output में print करते है |
  • सिर्फ एक ही character को declare कर सकते है | for eg. 'H'
  • अगर multiple character मतलब पूरे एक string को print करना हो तो '%s' का इस्तेमाल करते है |
  • Character Data Type 1 byte का होता है | |

for eg.
  #include <stdio.h>

  int main() {
  char str1='H'; // declare varible in single quotes
  char str2="H"; // declare varible in double quotes
  char str3[10]='Hello'; // Get Warning Error
  char str4[10]="Hello";
  printf("Single quoted Print Character: %c \n", str1);
  printf("Double quoted Print Character: %c \n", str2);
  printf("Single quoted Print String : %s \n", str3); //Get Warning Error
  printf("Double quoted Print String : %s \n", str4);

  return 0;
  }

Note : ऊपरवाला Program Warning Error देगा |Program में // Get Warning Error की lines हटाकर नीचेवाला Output दिया है | User single quotes और double quotes के बिच का फर्क जानने के लिए ऊपरवाला Program दिया है |

Output

Single quoted Print Character: H
Double quoted Print Character: $
Double quoted Print String : Hello

Character Data Types, Storage Size and Range

Data TypesStorage SizeRange
char1 Byte-128 to 127
unsigned char (16-bit)1 Byte0 to 255
signed char1 Byte--128 to 127

sizeof इस keyword से char Data Types के size का पता करे |
Source Code :
#include <stdio.h>

int main() {
printf("char storage size : %d \n", sizeof(char));
printf("unsigned char storage size : %d \n", sizeof(unsigned char));
printf("signed char storage size : %d \n", sizeof(signed char));

return 0;
}

Output

char storage size : 1
unsigned char storage size : 1
signed char storage size : 1

3. float (Floating-point)
  • Floating-point Data Type में variable को declare करने के 'float' keyword का इस्तेमाल करते है |
  • float को output में print करना हो तो '%f' format specifier से output में print करते है |
  • Floating-pont Data Type 4 bytes का होता है | |

for eg.
  #include <stdio.h>

  int main() {
  float a=5, b=3.145; // Type Casting convert integer value to print in float value
  printf("Value of Float variable : %f \n", a);
  printf("Value of b : %f \n", b);
  return 0;
  }

Output

Value of Float variable : 5.000000
Value of b : 3.145000

Floating-point Data Type, Storage Size and Range

Data TypesStorage SizeRangeDigits of Precision
float4 Bytes1.2E-38 to 3.4E+386

sizeof इस keyword से char Data Types के size का पता करे |
Source Code :
#include <stdio.h>

int main() {
printf("Floating-point Storage size : %d \n", sizeof(float));
return 0;
}

Output

Floating-point Storage size : 4

4. double
  • Double Data Type में variable को declare करने के 'double' keyword का इस्तेमाल करते है |
  • integer को output में print करना हो तो '%f', '%e', '%E', '%lf' format specifiers से output में print करते है |
  • Double Data Type 8 bytes का होता है | |
  • Double और Floating-point Data Type में कोई फर्क नहीं है |

for eg.
#include <stdio.h>

int main() {
double a=5;
printf("Value of Double variable : %lf \n", a);
printf("Value of Double variable : %e \n", a);
printf("Value of Double variable : %E \n", a);
return 0;
}

Output

Value of Double variable : 5.000000
Value of Double variable : 5.000000e+000
Value of Double variable : 5.000000E+000

Double Data Types, Storage Size and Range

Data TypesStorage SizeRangeDigits of Precision
double8 Bytes2.3E-308 to 1.7E+30815
long double10 Bytes3.4E-4932 to 1.1E+493219

sizeof इस keyword से char Data Types के size का पता करे |
Source Code :
#include <stdio.h>

int main() {
printf("Double Storage size : %d \n", sizeof(double));
return 0;
}

Output

Double Storage size : 8

5. void
  • void मतलब null value |
  • void में कोई value नहीं होती |
  • ये data type function और function के parameter / argument के लिए इस्तेमाल करते है |
  • ये कोई value return नहीं करता |

for eg.
#include <stdio.h>

void hello(void); // function with no return value and parameter
main()
{
hello();
}
void hello(void)
{
printf("Hello World");
}

Output

Hello World