here different macro constants are :
1. CHAR_MIN :
Minimum value for an object of type char
Value of CHAR_MIN is either -127 (-27+1) or less
2. CHAR_MAX :
Maximum value for an object of type char
Value of CHAR_MAX is either 127 (27-1) or 255 (28-1) or greater
3. SHRT_MIN :
Minimum value for an object of type short int
Value of SHRT_MIN is -32767 (-215+1) or less
4. SHRT_MAX :
Maximum value for an object of type short int
Value of SHRT_MAX is 32767 (215-1) or greater
5. USHRT_MAX :
Maximum value for an object of type unsigned short int
Value of USHRT_MAX is 65535 (216-1) or greater
6. INT_MIN :
Minimum value for an object of type int
Value of INT_MIN is -32767 (-215+1) or less
7. INT_MAX :
Maximum value for an object of type int
Value of INT_MAX is 32767 (215-1) or greater
8. UINT_MAX :
Maximum value for an object of type unsigned int
Value of UINT_MAX is 65535 (216-1) or greater
9. LONG_MIN :
Minimum value for an object of type long int
Value of LONG_MIN is -2147483647 (-231+1) or less
10. LONG_MAX :
Maximum value for an object of type long int
Value of LONG_MAX is 2147483647 (231-1) or greater
11. ULONG_MAX :
Maximum value for an object of type unsigned long int
Value of ULONG_MAX is 4294967295 (232-1) or greater
12. LLONG_MIN :
Minimum value for an object of type long long int
Value of LLONG_MIN is -9223372036854775807 (-263+1) or less
13. LLONG_MAX :
Maximum value for an object of type long long int
Value of LLONG_MAX is 9223372036854775807 (263-1) or greater
14. ULLONG_MAX :
Maximum value for an object of type unsigned long long int
Value of ULLONG_MAX is 18446744073709551615 (264-1) or greater
Program 2:To find the Maximum and Minimum Element in an array
#include <iostream>
#include <climits>
using namespace std;
int main()
{
int arr[100];
int maxNo=INT_MIN;
//maxN0 to find the maximum element and intializing it to INT_MIN
//here we are intializing it with INT_MIN becaues as soon as any number is greater than the minimum number the maximum number gets updated
//viceversa for minNo
int minNo=INT_MAX;
int n,i;
cout<<"enter number of elements u want to enter in the array";
cin>>n;// no of elements in the array user wants to enter
//reading elements into the array
cout<<"enter the elements in the array";
for(i=0;i<n;i++){
cin>>arr[i];
}
for(i=0;i<n;i++){
maxNo=max(maxNo,arr[i]);//using built in function max to find the max element
minNo=min(minNo,arr[i]);//using built in function min to find the min element
}
cout<<"maxNo is:"<<maxNo<<" "<<"minNo is:"<<minNo<<endl;
return 0;
}
Comments