How run infinite loops on c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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

27th Apr 2023, 3:10 AM
Abhishekprajapati
Abhishekprajapati - avatar
6 Answers
+ 8
int i = 0; while(true) { cout << i++; }
27th Apr 2023, 3:24 AM
A͢J
A͢J - avatar
+ 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
27th Apr 2023, 4:04 AM
Ipang
+ 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
27th Apr 2023, 5:08 AM
Orin Cook
Orin Cook - avatar
+ 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
27th Apr 2023, 11:09 PM
Orin Cook
Orin Cook - avatar
0
But why would you want to leave your computer stuck in an infinite loop?
27th Apr 2023, 7:46 AM
Rob Newman
Rob Newman - avatar
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
28th Apr 2023, 6:10 AM
Rob Newman
Rob Newman - avatar