C
C#2w ago
murns

Question

So I am learning to code C# I have a question. int x = 5; while (x > 0) { Console.Write(x); x--; if (x == 2) { x = 5; } } why would this equal 543543543543543543 opposed to 55555555555555555555555555555 I thought it would be "5555555555" as the console is writing before it minuses the integer
6 Replies
canton7
canton72w ago
Sure, but after it's written 5, what happens then?
murns
murnsOP2w ago
oh it loops back round duh sorry it was a stupid question, i just didnt look properly lol
SG97
SG972w ago
debugging line by line would also help to see the code flow
murns
murnsOP2w ago
yeah i understand it fully now, i think i just confused myself thank you x
canton7
canton72w ago
Cool, glad to hear! $close
MODiX
MODiX2w ago
If you have no further questions, please use /close to mark the forum thread as answered

Did you find this page helpful?