Why this is an infinite loop? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Why this is an infinite loop?

#include<iostream> using namespace std; int main() { string m="hash", n="unix"; for(int i=0;i=10;i++) { cout<<m+n<<endl; } }

4th Jun 2018, 6:02 AM
Harsh Kushwah
Harsh Kushwah - avatar
1 Antwort
+ 28
Because in condition section of for loop u are assigning value 10 to i and not comparing.... so condition never becomes false use this 👇 for(int i=0; i<=10; i++) or u can use i != 10 ==, <, >, etc... for comparing value = assign values
4th Jun 2018, 6:31 AM
🌛DT🌜
🌛DT🌜 - avatar