What does the output "Time limit exceeded" imply ?

In the code below why did i get output as "Time limit exceeded" #include <iostream> using namespace std; int main() { int a = 1; int b; int c =2; while (a<=7) { cin >> b; int b =+ c; } cout << b; return 0; }

10/24/2016 5:28:15 PM

Harshali Gayke

5 Answers

New Answer


you have an infinite loop in while, at the end you may write a++ so that it would stop eventually


you have infinite loop in while


Yup, as mentioned, you have an infinite loop, as well as a syntax error ( 'int b=+c' should be 'b+=c' ). You should also create another variable for the input since the value of b is being overwritten each loop iteration and will just return the last input + 2. I presume you want the total sum of the 7 inputs.


Time limit exceeded tends to happen when you have an infinite loop or your programs are just long. You know how this."learn c++" does not have the same cin process as a computer. It is supposed to not have a dialogue but should have been activated in order. The b=+ c should be b+= c and type your code onto a c++ complier. It should get compiled. But it is infinite so it has no output but only input which is like output. You could always make the loop stop by adding a++; or something like a+=2;.


int b+=c; maybe?