New course! Every coder should learn Generative AI!
Try a free lesson0
How run infinite loops on c++
#include <bits/std c++.h> Using namespace ; int main(){ Int i = 1; While (i <= 100){ Cout << I; i++; return(); }
6 Answers
+ 8
int i = 0;
while(true) {
cout << i++;
}
+ 6
Please use relevant tags for your post
And follow this guide next time you submit a post
https://www.sololearn.com/Discuss/333866/?ref=app
https://code.sololearn.com/W3uiji9X28C1/?ref=app
+ 3
there's also the old classic
for(;;){}
or even something fancier like
void loop(){
loop();
}
PS if you really want to give your computer a hard time don't forget to throw in some malloc abuse and pointers accessing random memory locations
+ 1
Rob Newman surprisingly real answer: learning how to break something on purpose is often the best way to learn how not to break it by accident
0
But why would you want to leave your computer stuck in an infinite loop?
0
Orin Cook good point , but if aware the concept can break it then learn how to avoid it.
Lesson is never use use functions and code you don't understand as danger by accident you break it.
While loops can be messy if no linked conditions