C PROGRAMMING

How to check size of data types in c

Data types

The kind of data that the variable may hold in a programming language is referred to as data types.


There are various types of data, such as Integer, character, real, string that a variable may contain in a programming language are named as Data types.

Any thing enclosed in ‘single quotes’ are character data. Number without fractions represents integer data type. Numbers with fractions represents floating point(real) data type. Any thing enclosed in “double quotes” are string data types.

Basic data types

There are two basic types of data in c as integer and floating point. With the help of these two data we can derive further two types(character and double precession) precession means how many digits can be used in a number. If you a temp to store a number with many digits such as 4.254655241(as floating point variable, only six digit 4.254655) will be retained.


The bytes occupied by each data type are shown in the table

Data Type Size in Bytes Range Use
char 1 –128 to 127 To store characters
int 2 –32768 to 32767 To store integer numbers
float 4 3.4E–38 to 3.4E+38 To store floating point numbers
double 8 1.7E–308 to 1.7E+308 To store big floating point numbers

#include<stdio.h>
main() {
int intType;
float floatType;
double doubleType;
char charType;
// sizeof evaluates the size of a variable
printf("Size of int: %u bytesn", sizeof(intType));
printf("Size of float: %u bytesn", sizeof(floatType));
printf("Size of double: %u bytesn", sizeof(doubleType));
printf("Size of char: %u byten", sizeof(charType));
}

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button