What are primary data types in C language?

CServer Side ProgrammingProgramming

‘C’ compilers support four fundamental data types. They are as follows −

  • Integer
  • Character
  • Floating − point
  • Double precision floating point

Primary Data Types

Integral data type

Integral data types are used to store whole numbers and characters.

It is further classified into two types −

  • Integer data type.
  • Character data type.

Integer data type

This data type is used to store whole numbers.

The integer storage are short int, int and long int in both signed and unsigned forms.

                                                                      Integer Data Types
Typesize(in bytes)RangeControl String
short in (or) signed short int1-128 to 127%h
unsigned short int10 to 255%uh
int (or) signed int4-32768 to 32767%d or %i
unsigned int40 to 65535%u
Long int (or) signed long int4-2147483648 to 2147483647%ld
Unsigned long int40 to 4294967295%lu

Character data type

Character data type is used to store characters only.

These characters are internally stored as integers.

Each character has an equivalent ASCII value.

For example, ‘A’ has ASCII value 65.

                                                                     Character  Data Types
TypeSize(in bytes)RangeControl String
Char(or) signed Char1-128 to 127%C
unsigned Char10 to 255%c

Floating - point Data type

Floating point data types are used to store real numbers.

float’ is used for 6 digits of accuracy.

‘double' is used for 12 digits of accuracy.

More than 12 digits, ‘long double’ is used.

                                                           Floating Point Data Types
Typesize(in bytes)RangeControl String
float43.4E - 38 to 3.4 E + 38%f
double81.7 E - 308 to 1.7 E + 308%lf
long double163.4 E - 4932 to 1.1 E + 4932%Lf
raja
Published on 09-Mar-2021 16:13:40
Advertisements