0

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; }

24th Oct 2016, 5:28 PM
Harshali Gayke
Harshali Gayke - avatar
5 Antworten
+ 12
you have an infinite loop in while, at the end you may write a++ so that it would stop eventually
24th Oct 2016, 5:55 PM
Nelli
Nelli - avatar
+ 1
you have infinite loop in while
24th Oct 2016, 5:35 PM
nekogami
nekogami - avatar
+ 1
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.
24th Oct 2016, 10:59 PM
Liam
Liam - avatar
+ 1
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;.
8th Nov 2016, 12:26 PM
Trey
0
int b+=c; maybe?
24th Oct 2016, 5:46 PM
Ruslan Psenicnyj
Ruslan Psenicnyj - avatar