C - Numeric types and their value range

Introduction

The following table lists C language variable types and also the range of values those types can store.

Type

Value Range

printf() Conversion
Character
_Bool
0 to 1
%d
char
-128 to 127
%c
unsigned char
0 to 255
%u
short int
-32,768 to 32,767
%d
unsigned short int
0 to 65,535
%u
int

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

unsigned int
0 to 4,294,967,295
%u
long int

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

unsigned long int
0 to 4,294,967,295
%lu
float
1.17?10^-38
to 3.40?10^38
%f
double
2.22?10-308 to 1.79?10308
%f

To store the value -10, you use a short int, int, or long int variable.

You cannot use an unsigned int as the following code demonstrates.

Demo

#include <stdio.h> 

int main() //from   w w  w.ja  v a 2s .c om
{ 
   unsigned int ono; 

   ono = -10; 
   printf("The value of ono is %u.\n",ono); 
   return(0); 
}

Result

Related Topic