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
2 Antworten
+ 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