Home » C++ programming language

ULONG_MAX constant with example in C++

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

C++ ULONG_MAX macro constant

ULONG_MAX constant is a macro constant which is defied in climits header, it is used to get the maximum value of an unsigned long int object, it returns the maximum value that an unsigned long int object can store, which is 18446744073709551615 (on 32 bits compiler).

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 ULONG_MAX constant is defined in both of the libraries.

Syntax of ULONG_MAX constant:

    ULONG_MAX

Example:

    Constant call:
    cout << ULONG_MAX;

    Output:
    18446744073709551615

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

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

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

Output

ULONG_MAX: 18446744073709551615

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

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

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

Output

ULONG_MAX: 18446744073709551615



Comments and Discussions!

Load comments ↻






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