Didn't get the difference between while (num++<5) and while (++num <5)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Didn't get the difference between while (num++<5) and while (++num <5)?

14th Apr 2017, 3:42 AM
Khadija Afzaal
Khadija Afzaal - avatar
8 Answers
+ 8
umm...Where does this come from? I can't really help you without knowing the origin, and the true question you have about this code.
14th Apr 2017, 3:48 AM
SoraKatadzuma
SoraKatadzuma - avatar
+ 8
Right, but I mean in the courses of the app? Your own code? Someone else's code? I can tell you the difference but I have no idea what kind of effect it has on the code it comes from (be it the course examples, your code or someone else's code).
14th Apr 2017, 4:05 AM
SoraKatadzuma
SoraKatadzuma - avatar
+ 8
@Rrestoring faith, you beat me to it XD
14th Apr 2017, 5:09 AM
SoraKatadzuma
SoraKatadzuma - avatar
+ 6
++x increments before using x. So if x was 4 prior to the loop: (1+4<5) the loop will terminate. x++ increments after using x. So if x was 4 prior to the loop: (4<5) the loop will continue, however after the comparison x becomes 5.
14th Apr 2017, 5:06 AM
Rrestoring faith
Rrestoring faith - avatar
14th Apr 2017, 5:16 AM
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender)
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender) - avatar
+ 1
int x=1 while (x++<5) conslole.writeline (x); what if i write int x=1 while (++x <5) console.writeline (x);
14th Apr 2017, 4:09 AM
Khadija Afzaal
Khadija Afzaal - avatar
0
This comes from while loop
14th Apr 2017, 3:59 AM
Khadija Afzaal
Khadija Afzaal - avatar
0
miguel silva
20th Apr 2017, 7:52 AM
Dan Mabulac
Dan Mabulac - avatar