× Home Variables Data types
Next Lec → ← Previous Lec

Variables & Data Types in C

Declaration

Rules for defining a variable in C

Data Types in C

Data Types: Size (32-bit architecture)

DATA TYPE

MEMORY (BYTES)

RANGE

Char

1 byte = 8 bits

-128 to 127

signed char

1

-128 to 127

unsigned char

1

0 to 255

short int

2

-32,768 to 32,767

unsigned short int

2

0 to 65,535

unsigned int

4

0 to 65,535

int

2

--32,768 to 32,767

long int

4

-2,147,483,648 to 2,147,483,647

unsigned long int

4

0 to 4,294,967,295

float

4

double

8

long double

10

Code for finding the size of data types

                        

                                #include <stdio.h>
                                int main() {
                                    printf("%lu\n", sizeof(int));
                                    printf("%lu\n", sizeof(char));
                                    printf("%lu\n", sizeof(long));
                                    // 'lu' is used for unsigned long
                                    return 0;
                                } 
                        
                    

output:
4
1
4