+ 1
How these loop execute ?
for(x=0;x=10;x++);
5 Answers
+ 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;
}
+ 2
It's an infinite loop if you wrap the condition in parentheses.
+ 1
Shubham Maske
#include <iostream>
int main() {
for(int x=0;x < 10;x++) {
std::cout << x << std::endl; }
return 0;
}
+ 1
The condition for the entry of the loop is wrong
+ 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