## Determine the size and limit of a variable in C

We can easily determine the size and limit of any data type of our system. In this article we will see some program to determine the size and limit of a data type in C.

Determine the size of a data type : We will use the sizeof() operator to determine the size of any data type. The sizeof() operator returns the allocated memory for that data type. We can easily find the size of a primitive data type using this operator. Let’s take an example program to find the size of data type in C.

## C program to find the size of a variable

``````// c program to determine the size of data type

#include<stdio.h>

int main(){

printf("Size of char of your system is = %d byte.\n\n", sizeof(char));

printf("Size of integer of your system is = %d bytes.\n\n", sizeof(int));

printf("Size of long integer of your system is = %d bytes.\n\n", sizeof(long int));

printf("Size of long long integer of your system is = %d bytes.\n\n", sizeof(long long int));

printf("Size of float of your system is = %d bytes.\n\n", sizeof(float));

printf("Size of double of your system is = %d bytes.\n", sizeof(double));

return 0;
}``````

### Output of this size of variable program: Maximum or minimum value of a data type : To determine the maximum or minimum value of a data type we use some library functions which is under limits.h header file. The maximum limits refers the maximum value that a data type can hold where the minimum limits is the minimum value of data which a data type can hold.

## Find maximum and minimum value of variable

``````// c program to find minimum and maximum value of data type

#include <stdio.h>
#include <limits.h>

int main(){
printf("Maximum integer value of your system is = %d\n\n", INT_MAX);

printf("Minimum integer value of your system is = %d\n\n", INT_MIN);

printf("Maximum long int value is = %ld\n\n", LONG_MAX);

printf("Minimum value of long int is = %ld\n\n", LONG_MIN);

printf("Maximum value of long long int is = %lld\n\n", LLONG_MAX);

printf("Minimum value of long long int is = %lld\n", LLONG_MIN);

return 0;
}``````

### Output of min and max value program:

``````Maximum integer value of your system is = 2147483647

Minimum integer value of your system is = -2147483648

Maximum long int value is = 2147483647

Minimum value of long int is = -2147483648

Maximum value of long long int is = 9223372036854775807

Minimum value of long long int is = -9223372036854775808``````

You can take help about size and limit of variable from our limits.h header file. This header file contains all the library function to determine the maximum and minimum value of any data type.

Previous pageReverse an array

Next pageASCII value of characters