Maximum value of short int in C++ Last Updated : 05 Jan, 2023 Comments Improve Suggest changes Like Article Like Report In this article, we will discuss the short int data type in C++. This data type in C++ is used to store 16-bit integers. Some properties of the short int data type are: Being a signed data type, it can store positive values as well as negative values.Takes a size of 16 bits, where 1 bit is used to store the sign of the integer.A maximum integer value that can be stored in a short int data type is typically 32767, around 215-1(but is compiler dependent).The maximum value that can be stored in short int is stored as a constant in <climits> header file. Whose value can be used as SHRT_MAX.The minimum value that can be stored in short int is stored as a constant in <climits> header file. Whose value can be used as SHRT_MIN.A minimum integer value that can be stored in a short int data type is typically -32768 around (-215+1) (but is compiler dependent).In case of overflow or underflow of data type, the value is wrapped around. For example, if -32768 is stored in a short int data type and 1 is subtracted from it, the value in that variable will become equal to 32767. Similarly, in the case of overflow, the value will round back to -32768. Below is the program to get the highest value that can be stored in unsigned long long int in C++: C++ // C++ program to obtain themaximum // value that can be store in short int #include <climits> #include <iostream> using namespace std; // Driver Code int main() { // From the constant of climits // header file short int valueFromLimits = SHRT_MAX; cout << "Value from climits " << "constant (maximum): " << valueFromLimits << "\n"; valueFromLimits = SHRT_MIN; cout << "Value from climits " << "constant (minimum): " << valueFromLimits << "\n"; // Using the wrap around property // of data types // Initialize two variables with // -1 as previous and 0 as present short int previous = -1; short int present = 0; // Increment both values until the // present increases to the max limit // and wraps around to the negative // value i.e., present becomes less // than the previous value while (present > previous) { previous++; present++; } cout << "Value using the wrap " << "around property :\n"; cout << "Maximum: " << previous << "\n"; cout << "Minimum: " << present << "\n"; return 0; } Output:Value from climits constant (maximum): 32767 Value from climits constant (minimum): -32768 Value using the wrap around property : Maximum: 32767 Minimum: -32768 Time Complexity: O(N)Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article How to Find the Maximum Element of a Vector using STL in C++? U UtkarshPandey6 Follow Improve Article Tags : Misc C++ Programs C++ Data Types Data Type +1 More Practice Tags : CPPData TypeMisc Similar Reads Maximum value of unsigned int in C++ In this article, we will discuss the maximum value of unsigned int in C++. Unsigned int data type in C++ is used to store 32-bit integers.The keyword unsigned is a data type specifier, which only represents non-negative integers i.e. positive numbers and zero. Some properties of the unsigned int dat 2 min read Maximum value of long long int in C++ In this article, we will discuss the long long int data type in C++. long long int data type in C++ is used to store 64-bit integers. It is one of the largest data types to store integer values, unlike unsigned long long int both positive and negative. Some properties of the long long int data type 2 min read Maximum value of unsigned char in C++ In this article, we will discuss the maximum value of unsigned char data type in C++. Some properties of the unsigned char data type are: Being an unsigned data type, it can store only positive values.Unsigned char data type in C++ is used to store 8-bit characters.A maximum value that can be stored 2 min read Maximum value of unsigned long long int in C++ In this article, we will discuss the unsigned long long int data type in C++. It is the largest (64 bit) integer data type in C++. Some properties of the unsigned long long int data type are: An unsigned data type stores only positive values.It takes a size of 64 bits.A maximum integer value that ca 2 min read How to Find the Maximum Element of a Vector using STL in C++? Given a vector, find the maximum element of the vector using STL in C++. ExampleInput: v = {2, 4, 1, 5, 3}Output: 5Explanation: 5 is the largest element of vector.Input: v = {11, 23, 3, 5, 24}Output: 24Explanation: 24 is the largest element of the given range.STL provides the following different met 3 min read How to Find the Maximum Element of a Vector using STL in C++? Given a vector, find the maximum element of the vector using STL in C++. ExampleInput: v = {2, 4, 1, 5, 3}Output: 5Explanation: 5 is the largest element of vector.Input: v = {11, 23, 3, 5, 24}Output: 24Explanation: 24 is the largest element of the given range.STL provides the following different met 3 min read Like