Size and Limits of Datatypes in C Language

Spread the love

Size-and-limits-of-datatypes-in-programming-language

Program Introduction:

In this article, We are going to write a program to calculate the size and limits of Datatypes in C programming.

The Limits of datatype mean, The Minimum allowed value and Maximum allowed value for a given datatype.

Example Size and limits of datatypes in C:

Let’s take character datatype. The size of character datatype is one ( 1 ) Byte.

And Limits of character datatype are Maximum available value is 127 and the Minimum value is -128.

So similar way we need to calculate the size and minimum and maximum limit of all datatypes of c programming language

Size and Limits of Datatypes in C Programming:

We are going to use the built-in sizeof operator to calculate the size of each datatype.

We calculate the Maximum limit and Minimum limit of a datatype using the C programming language limits.hlibrary.

The limits.hlibrary contains the Macros with all available variables Minimum limit and Maximum Limit.

For Example, To get the minimum value of the Integer variable, You first need to include the limits.h Library to your program. Then use the Macros INT_MINand INT_MAX of climit.h library. The INT_MINMacro provides the Minimum allowed integer value and The INT_MAX contains the Maximum allowed Integer value.

Similarly, We can calculate the Minimum value and Maximum value of all available datatypes of C Language.

Program: Size and Limits ( Minimum and Max ) of all datatypes in C:

We are using the climit.h library for getting the limits

In the above program, We calculated Min and Max of all datatypes. We also displaying the precision of all floating point datatypes like float, double, and Long double.

Program Output:

We are compiling the program using the gcc compiler.

Here is my original output.

size-and-limits-of-datatypes-in-c-programming-language

The Size and Min, Max Values of all Datatypes

Here is the summary of above output.

Conclusion:

In this article, We have discussed the sizes of all datatypes in the C Language. We also looked into the maximum allowed value and minimum limit of all C language datatypes like integer, float, and characters, etc. We also looked at the precision of floating-point datatypes.

Related Reading:

Venkey

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

2 Responses

  1. May 31, 2021

    […] Size and Limits of Datatypes in C Language – SillyCodes […]

  2. May 31, 2021

    […] Size and Ranges (Limits) of all Datatypes […]

Leave a Reply