Suppose a loop continuously printing something. Till how long it will continue to do so? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Suppose a loop continuously printing something. Till how long it will continue to do so?

Is it related to hard drive size of computer?

11th Aug 2016, 11:14 AM
Preet
Preet - avatar
2 Answers
+ 2
It will not stop. If you made an infinite loop, then your program will simply do just that. Games even run on loops, not infinite, but a LOT of loop iterations while the game is running. The code playground doesn't allow infinite loops as it says time limit exceeded, but on any regular IDE, it will just be continuous output. while (true) { std::cout << "hi"; }
11th Aug 2016, 2:00 PM
Cohen Creber
Cohen Creber - avatar
+ 1
Till the output buffer runs out of memory it will execute. Memory is not infinite.
12th Aug 2016, 8:29 PM
sidharth arora
sidharth arora - avatar