← Discussion

calcute a+b

~recursive · 2016-05-19 00:19:42

my code is:

include

using namespace std; int main() { int a,b; while(1) { cin>>a>>b; cout<<a+b<<endl; } return 0; } why the system give me "Output Limit Exceeded"???? plaese help me :-(

Hita Barasm Mamagani · 2016-05-19 15:42:57

~recursive said:

my code is:

include

using namespace std; int main() { int a,b; while(1) { cin>>a>>b; cout<<a+b<<endl; } return 0; } why the system give me "Output Limit Exceeded"???? plaese help me :-(

Hi, because you use while(1) so the program will never end. if you use while(cin>>a>>b) it will work fine, and accepted!

Sajad Ahmadi · 2016-05-23 09:09:01

include

using namespace std;

while (cin >> a >> b)
    cout <<a+b<< endl ;
pages:
  • 1