C++ program for printing the range data type like int, char, short.
Signed Data Types
METHOD 1.) calculate total number of bits by multiplying sizeof with 8 (say n) 2.) Calculate -2^(n-1) for minimum range 3.) Calculate (2^(n-1))-1 for maximum range
signed char: -128 to 127 signed int: -2147483648 to 2147483647 signed short int: -32768 to 32767
Unsigned Data Types
METHOD 1.)Find number of bits by multiplying result of sizeof with 8 say n 2.)minimum range is always zero for unsigned data type 3.)for maximum range calculate 2^n-1
unsigned char: 0 to 255 unsigned int: 0 to 4294967295 unsigned short int: 0 to 65535
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- What happen when we exceed valid range of built-in data types in C++?
- Difference between fundamental data types and derived data types
- C++ Data Types
- Different types of range-based for loop iterators in C++
- Derived Data Types in C++
- What are the data types for which it is not possible to create an array?
- User defined Data Types in C++
- Uninitialized primitive data types in C/C++
- Interesting facts about data-types and modifiers in C/C++
- Queries for elements having values within the range A to B in the given index range using Segment Tree
- Program to calculate Electricity Bill
- Calculate area of pentagon with given diagonal
- Macros and its types in C/C++
- Enumerated Types or Enums in C++
- Types of Literals in C/C++ with Examples
- Types of Operator Overloading in C++
- Runtime Polymorphism in various types of Inheritance in C++
- Introduction of Smart Pointers in C++ and It's Types
- C++ default constructor | Built-in types
- Extended Integral Types (Choosing the correct integer size in C/C++)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.