## Data Types and Sizes in C

**By:** Priya Printer Friendly Format

char |
a single byte, capable of holding one character in the local character set |

int |
an integer, typically reflecting the natural size of integers on the host machine |

float |
single-precision floating point |

double |
double-precision floating point |

In addition, there are a number of qualifiers that can be applied to these
basic types. `short` and `long` apply to integers:

short int sh; long int counter;The word

`int`can be omitted in such declarations, and typically it is.

The intent is that `short` and `long` should provide different
lengths of integers where practical; `int` will normally be the natural
size for a particular machine. `short` is often 16 bits long, and `int`
either 16 or 32 bits. Each compiler is free to choose appropriate sizes for its
own hardware, subject only to the the restriction that `short`s and ints
are at least 16 bits, `long`s are at least 32 bits, and `short` is
no longer than `int`, which is no longer than `long`.

The qualifier `signed` or `unsigned` may be applied to `char`
or any integer. `unsigned` numbers are always positive or zero, and obey
the laws of arithmetic modulo *2 ^{n}*, where

*n*is the number of bits in the type. So, for instance, if

`char`s are 8 bits,

`unsigned char`variables have values between 0 and 255, while

`signed char`s have values between -128 and 127 (in a two's complement machine.) Whether plain

`char`s are signed or unsigned is machine-dependent, but printable characters are always positive.

The type `long double` specifies extended-precision floating point. As
with integers, the sizes of floating-point objects are implementation-defined; `float`,
`double` and `long double` could represent one, two or three
distinct sizes.

The standard headers `<limits.h>` and `<float.h>`
contain symbolic constants for all of these sizes, along with other properties
of the machine and compiler.

Comment on this tutorial

- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview

#### categories

#### Subscribe to Tutorials

#### Related Tutorials

Sum of the elements of an array in C

Printing a simple histogram in C

Find square and square root for a given number in C

Simple arithmetic calculations in C

Passing double value to a function in C

Passing pointer to a function in C

Infix to Prefix And Postfix in C

while, do while and for loops in C