-2
cout <<"The size of a integer is " << sizeof(int) << "bytes and the range is: " << INT_MIN << " to " << INT_MAX <<endl;

cout <<"The size of an unsigned integer is " <<sizeof(unsigned int) << "bytes and the range is: "
    <<std::numeric_limits<unsigned int>::min() << " to " <<std::numeric_limits<unsigned int>::max() <<endl;

std::cout <<"The size of a short integer is " <<sizeof(short int) << "bytes and the range is: "
    <<std::numeric_limits<short int>::min() << " to " <<std::numeric_limits<short int>::max() <<endl;

cout <<"The size of an unsigned short integer is " <<sizeof(unsigned short int) << "bytes and the range is: "
    <<std::numeric_limits<unsigned short int>::min() << " to " << std::numeric_limits<unsigned short int>::max() <<endl;

cout <<"The size of an long integer is " << sizeof(long int) << "bytes and the range is: " 
    << std::numeric_limits<long int>::min() << " to " << std::numeric_limits<long int>::max() << endl;

cout << "The size of an unsigned long integer is " << sizeof(unsigned long int) << "bytes and the range is: " 
    <<std::numeric_limits<unsigned long int>::min() << " to " << std::numeric_limits<unsigned long int>::max() << endl;

cout << "The size of a character is " << sizeof(char) << "bytes and the range is: " 
    <<std::numeric_limits<char>::min() << " to " << std::numeric_limits<char>::max() << endl;

    cout << "The size of a unsigned character is " << sizeof(unsigned char) << "bytes and the range is: " 
    <<std::numeric_limits<unsigned int>::min() << " to " << std::numeric_limits<unsigned int>::max() << endl;

std::cout << "The size of a float is " << sizeof(float) << "bytes and the range is: " 
    <<std::numeric_limits<float>::lowest() << " to " << std::numeric_limits<float>::max() << endl;

    cout << "The size of a wchar_t is " << sizeof(wchar_t) << "bytes and the range is: " 
    <<std::numeric_limits<wchar_t>::min() << " to " << std::numeric_limits<wchar_t>::max() << endl;

    cout << "The size of a double is " << sizeof(double) << "bytes and the range is: " 
    <<std::numeric_limits<double>::min() << " to " << std::numeric_limits<double>::max() << endl;

    cout << "The size of a long double is " << sizeof(long double) << "bytes and the range is: " 
    <<std::numeric_limits<long double>::min() << " to " << std::numeric_limits<long double>::max() << endl;

    cout << "The size of a long is " << sizeof(long) << "bytes and the range is: " 
    <<std::numeric_limits<long>::min() << " to " << std::numeric_limits<long>::max() << endl;

    cout << "The size of an unsingned long is " << sizeof(unsigned long) << "bytes and the range is: " 
    <<std::numeric_limits<unsigned long>::min() << " to " << std::numeric_limits<unsigned long>::max() << endl;

    cout << "The size of a long long  is " << sizeof(long long) << "bytes and the range is: " 
    <<std::numeric_limits<long long>::min() << " to " << std::numeric_limits<long long>::max() << endl;

    cout << "The size of an unsingned long long is " << sizeof(unsigned long long) << "bytes and the range is: "
    <<std::numeric_limits<unsigned int>::min() << " to " << std::numeric_limits<unsigned int>::max() << endl;

    cout << "The size of a boolean is " << sizeof(bool) << "bytes and the range is: " <<std::numeric_limits<bool>::min() << " to " 
        << std::numeric_limits<bool>::max() <<"\n\n\n\n"<< endl;

The code keeps showing me errors; I don't know what I am not doing. It is suppose to show me the size and range of all these data types and modifiers. The min keeps being highlighted and I see errors about expecting an identifier. Please help; I have searched so much through google.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Remy
  • 1
  • 4

2 Answers2

0

You need to consistently use std:: for all the names in the std namespace. (Or you can use using namespace std;)

And you need to include the correct headers:

#include <iostream>
#include <limits>

Windows:

(Information taken from #define NOMINMAX using std::min/max): Also, if you are have #include <windows.h> (which I don't think is necessary but what do I know about Windows), you need to avoid the non-standard min and max macros from being expanded by writing, for example:

(std::numeric_limits<long double>::min)()

or, apparently, you can #define NOMINMAX before any #include.

Community
  • 1
  • 1
rici
  • 234,347
  • 28
  • 237
  • 341
  • again i use all of that. stilll dont see anything i havent tried well except for the define nominmax. im going to try and let yall know. – Remy Jun 30 '15 at 03:30
0

CODE is working fine if you change lowest() in line no 23 to min() . Did you include limits header? This is what I am getting output as:

The size of an unsigned integer is 4bytes and the range is: 0 to 4294967295
The size of a short integer is 2bytes and the range is: -32768 to 32767
The size of an unsigned short integer is 2bytes and the range is: 0 to 65535
The size of an long integer is 8bytes and the range is: -9223372036854775808 to 9223372036854775807
The size of an unsigned long integer is 8bytes and the range is: 0 to 18446744073709551615
The size of a character is 1bytes and the range is: � to 
The size of a unsigned character is 1bytes and the range is: 0 to 4294967295
The size of a float is 4bytes and the range is: 1.17549e-38 to 3.40282e+38
The size of a wchar_t is 4bytes and the range is: -2147483648 to 2147483647
The size of a double is 8bytes and the range is: 2.22507e-308 to 1.79769e+308
The size of a long double is 16bytes and the range is: 3.3621e-4932 to 1.18973e+4932
The size of a long is 8bytes and the range is: -9223372036854775808 to 9223372036854775807
The size of an unsingned long is 8bytes and the range is: 0 to 18446744073709551615
The size of a long long  is 8bytes and the range is: -9223372036854775808 to 9223372036854775807
The size of an unsingned long long is 8bytes and the range is: 0 to 4294967295
The size of a boolean is 1bytes and the range is: 0 to 1
Madhu Kumar Dadi
  • 695
  • 8
  • 25
  • is you run the program or me. i said it doesnt work and dont watch the part about lowest , i was just testing that and forgot to change it back with the rest. – Remy Jun 30 '15 at 03:29
  • it is running `The size of an unsigned integer is 4bytes and the range is: 0 to 4294967295 The size of a short integer is 2bytes and the range is: -32768 to 32767 The size of an unsigned short integer is 2bytes and the range is: 0 to 65535 The size of an long integer is 8bytes and the range is: -9223372036854775808 to 9223372036854775807 The size of an unsigned long integer is 8bytes and the range is: 0 to 18446744073709551615 The size of a character is 1bytes and the range is: � to The size of a unsigned character is 1bytes and the range is: 0 to 4294967295 and so on .... – Madhu Kumar Dadi Jun 30 '15 at 03:35
  • coming to char you can't print char '0' and '255' so I am getting some waste. – Madhu Kumar Dadi Jun 30 '15 at 03:36
  • could i get your email and send you my entire code for you to try please. im seriously frustrated and dont know what else to do. the rest of my code works fine when i comment out the part about range. – Remy Jun 30 '15 at 03:49
  • you can write your whole code in your question.Can't you? – Madhu Kumar Dadi Jun 30 '15 at 03:51
  • I suggest you to write your whole code in the question including `#include ` directories. – Madhu Kumar Dadi Jun 30 '15 at 03:55
  • ok i will but its alot cause that range is only a small part but huge part – Remy Jun 30 '15 at 04:05
  • this site is being its usual annoying self i cant edit that code. i cant bother, i always come here as last resort and can never get proper help. too complicated. forget it. – Remy Jun 30 '15 at 04:11
  • if anyone really want to help i will be at diva-remy.com/chatroom – Remy Jun 30 '15 at 04:17