I declare an integer and input value from user when i check this program i give the value 40,000 its a overflow but program generate no any type of error why?

It would be a lot easier to answer that if you posted the code.

#include<iostream>
using namespace std;
int main()
{
    int n;
    cout<<"Enter number"<<endl;
    cin>>n;
    cout<<"You enter:"<<n<<endl;
    system("pause");
    return 0;
}

when i enter 9999999999 than it shows error that output is you enter 2147483647

It would seem that int declares a 32 bit signed integer. You could try

long long unsigned int n;

but you'd still end up with a problem if you added a few more digits to the input string.

As to why an error is not generated that might depend of one or more compiler switches/options. I used the defaults in Visual Studio 2012 and also did not get an error.

The C++11 Standard says that signed integer overflow/underflow behaviour is "undefined", so any compiler can legally do whatever it wants, including ignore it. Ignoring it (on normal computers) is a lot easier and faster that detecting it and doing something sensible. That's C++ for you.

8.4: If during the evaluation of an expression, the result is not mathematically defined or not in the range of representable values for its type, the behavior is undefined.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.