Primitive Data Types In C Language

Primitive Data Types In C Language

    Hi guys, in this section we will discuss Primitive Data Types and their types also. This section is essential because it is also considered a long question for Computer Science subjects. So without wasting time let's get started.

Primitive Data Types:

    In C language primitive data types are as follows:
  • Integer Data Types
  • Floating Point Data Types
  • Double Data Types
  • Character Data Types
  • Void Data Types
    Let's discuss all the Data Types briefly.

Integer Data Types:

  • Integer data type allows a variable to store integer values.
  • The 'int' keyword is used to refer to integer data types.
  • The storage size of the int data type is 2 bytes/ 4 bytes / 8 bytes. (It varies according to our processor)
  • Examples:
      • 16-bit processor — 2-byte int reserve
      • 32-bit processor — 4-byte int reserve
      • 64-bit processor — 8-byte int reserve
  • If we want to use the integer value that crosses the above limit, then we can use 'long int' and 'long long int'.
  • Here are some examples:
      • int b = 3;
      • int c= 78;
      • long k = 123456;
      • long long s = 123456789;
  • Note: 'long' is equivalent to 'long int' and 'long long int' is equivalent to 'long long'.

Floating Point Data Types:

  • The floating point data type allows a variable to store decimal values or fractional values.
  • The 'float' keyword is used to refer floating point data type.
  • The storage size of the float data type is 4 bytes.
  • This data type allows us to use up to 6 digits after the decimal point. For example, 8.5678654 can be stored in a variable using float data type.
  • Here are some examples:
      • float f = 4.45;
      • float t = 5.90;
      • float h = 3.0;

Double Data Types:

  • The double data type is the same as the floating point data type.
  • The 'double' keyword is used to refer to double data type.
  • The storage size of the double data type is 8 bytes.
  •  This data type allows us to use up to 10 digits after the decimal point.
  • Examples:
      • double d = 5.5673;
      • double g = 8.8767895439;

Character Data Types:

  • Character data type allows a variable to store only one character.
  • The 'char' keyword is used to refer to character data type.
  • The storage size of the character data type is 1 byte.
  • Character values are represented within a single quote. ('...')
  • Examples:
      • char = 'A';
      • char = 'b';

Void Data Types:

  • The void data type is a data type that is mainly used with functions.
  • The void type has no values.
  • The type of function is said to be void when it does not return any value to the calling function.
  • Examples:
      • void display();
      • void findSum();
That's all for this section, you can also watch videos on YouTube for more information about this concept.

Post a Comment