Home » C++ programming language

SHRT_MIN constant with example in C++

C++ SHRT_MIN constant: Here, we are going to learn about the SHRT_MIN macro constant of climits header in C++.
Submitted by IncludeHelp, on May 01, 2019

C++ SHRT_MIN macro constant

SHRT_MIN constant is a macro constant which is defied in climits header, it is used to get the minimum value of a short int object, it returns the minimum value that a short int object can store, which is -32768.

Note:

  • The actual value depends on the compiler architecture or library implementation.
  • We can also use <limits.h> header file instead of <climits> header as SHRT_MIN constant is defined in both of the libraries.

Syntax of SHRT_MIN constant:

    SHRT_MIN

Example:

    Constant call:
    cout << SHRT_MIN;

    Output:
    -32768

C++ code to demonstrate example of SHRT_MIN constant with climits header

// C++ code to demonstrate example of 
// SHRT_MIN constant with climits header
#include<iostream>
#include<climits>
using namespace std;

int main()
{
   //prinitng the value of SHRT_MIN
    cout<<"SHRT_MIN: "<<SHRT_MIN<<endl;
    return 0;
}

Output

SHRT_MIN: -32768 

C++ code to demonstrate example of SHRT_MIN constant with limits.h header file

// C++ code to demonstrate example of 
// SHRT_MIN constant with <limits.h> header file
#include<iostream>
#include<limits.h>
using namespace std;

int main()
{
   //prinitng the value of SHRT_MIN
    cout<<"SHRT_MIN: "<<SHRT_MIN<<endl;
    return 0;
}

Output

SHRT_MIN: -32768 


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.