Create and use Unsigned Integer Types - C Data Type

C examples for Data Type:int

Introduction

For each type that stores signed integers, there is a corresponding type that stores unsigned integers.

The unsigned type occupies the same amount of memory as the signed type.

Each unsigned type name is the signed type name prefixed with the keyword unsigned.

The following table shows the basic unsigned integer types that you can use.

Type name Number of bytes
unsigned char 1
unsigned short or unsigned short int2
unsigned int4
unsigned long or unsigned long int 4
unsigned long long or unsigned long long int8

A 32-bit integer variable can represent any of 4,294,967,296 different values.

Here are examples of unsigned integer variable declarations:

Demo Code

#include <stdio.h>

int main(void)
{
    unsigned int count;
    unsigned long population;

    count = 1000;/*from w ww  . ja  v  a  2s .co  m*/

    printf("%d",count);
    
    return 0;
}

Result


Related Tutorials