+ 1

How these loop execute ?

for(x=0;x=10;x++);

8th Mar 2021, 2:33 AM
Shubham Maske
Shubham Maske - avatar
6 Respuestas
+ 4
Shubham Maske If you print value of x then this loop will work till infinite because after incrementing value of x you again assign with 10 (x=10) so output will be 10101010101010101010................. Execution Timeout. Try this code in Code Playground. int x = 0; for (x = 0; x = 10; x++) { cout << x; }
8th Mar 2021, 8:46 AM
A͢J
A͢J - avatar
+ 2
It's an infinite loop if you wrap the condition in parentheses.
8th Mar 2021, 2:49 AM
Ipang
+ 1
Shubham Maske #include <iostream> int main() { for(int x=0;x < 10;x++) { std::cout << x << std::endl; } return 0; }
8th Mar 2021, 3:54 AM
BroFar
BroFar - avatar
+ 1
The condition for the entry of the loop is wrong
8th Mar 2021, 11:25 AM
Atul [Inactive]
+ 1
for(x=0;x=10;x++); Output; null This condition is stop , don't executed the loop. for(x=0;x=10;x++) { Printf(x); } Output 0123456789
9th Mar 2021, 3:05 PM
R YUVARAJ
R YUVARAJ - avatar