Signed Integer Types - C++ Data Type

C++ examples for Data Type:Introduction

Introduction

The following table lists the complete set of types that store signed integers.

The signed integers can have both positive and negative values.

Type Name Typical Size (bytes) Range of Values
signed char1-128 to 127
short 2-256 to 255
int4-2,147,483,648 to +2,147,483,647
long or long int 4-2,147,483,648 to +2,147,483,647
long long or long long int 8-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Here are some examples of variables of some of these types:

Demo Code

#include <iostream>

int main() {//from  w ww  .ja  v  a2s.  c  o  m
    signed char ch {20};
    long temperature {-50L};
    long width {500L};
    long long height {250LL};
    unsigned int toe_count {10U};
    unsigned long angel_count {1000000UL};

  std::cout << "The value of char is "  << ch  << std::endl;
  std::cout << "The value of temperature is " << temperature << std::endl;
  std::cout << "The value of height is "  << height  << std::endl;
}

Result


Related Tutorials