+ 1
What is the largest number that will be printed by this code? Explain(Detail by Detail) plz.
for (int x = 1; x < 8; x++) { if (x > 5) break; Console.WriteLine(x); } //Oh and what does the break; do in this code exactly
3 Antworten
+ 5
5
cause that will print 1, 2, 3, 4, 5 then x wil be 6 and 6 > 5 so the break will get execute and that will tell the program to stop executing that loop so it wont print the last value of x that is 6 cause the break will stop the loop
+ 1
Thank You a lot :)
0
This is wrong explanation. As "if" wont execute until condition satisfied. But it will still print the no.s. So the output will be like this:
1
2
3
4
5
Highest:5
#loops #break