Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
C# postfix in do while loop š¤š¤ Help plz!
int i =1 , j=5 ; do { Console.WriteLine(i=i++*j); }while (i<=10); I am really confused with this question why the output equals 5,25 not 5,30 ?! Why it doesnāt increment i ? https://code.sololearn.com/c27w2ZT26HM4/?ref=app
7 Respostas
+ 4
When i = 1
i = i++ * j
-> i = 1 * 5
-> 5
Is i <= 10? Yes, continue.
i = i++ * j
-> i = 5 * 5
-> 25
Is i <= 10? No, loop ends.
+ 2
Nada Hossam ah yeah, but you were only doing with i variable as I observed your code, you didn't do the same thing in j to get 6 * 5.
sooo, here's the solution, which I fixed it by putting an increment to j.
https://code.sololearn.com/cjpMQQTAi9jr/?ref=app
+ 1
but why it doesnāt increment i to be 6 * 5 ?? as a postfix it wonāt change in the same line and then it should be incremented by 1 in the next line , isnāt true ?
+ 1
try putting the increment statement outside of the writine for clearance
+ 1
Can you add a link to your code? it is easier to test š
0
Coding Kitty[exams] I am really gratful to you šø but I guess you didnāt understand what I am confused with , the above question itās answer is 5,25 and I canāt understand why .
I am a beginner š
0
CarrieForle
Thanks alot