0
Pleaze why 6 is printed in this code ???? 6<6;???
12 Respostas
+ 2
It is because when the code starts executing first the num is checked for the previous value but it prints the next value.
So in the last iteration the num will be checked for 5<6 which is true & because of post increment it increments later which becomes 6 & since the condition is true the control comes inside while & Prints 6.
â If you will observe it starts from 1 not from 0 even when num is set to 0 so it is obvious it will give one extended value bacause it is starting from one extended value so it will end with one extended value also.
-------------------------------------------------
I hope it helps.
+ 2
you're welcome
+ 1
oh thx rahul finally i get it ^^ thank you so much
0
try this
while(num < 6){
Console.WriteLine(num);
num++;
}
the mistake you made is that you didn't make num increasing so it would be an infinite loop
0
really? đ
0
yep
0
I am asking why 6 is printed
0
I have no idea.
0
xD
0
oh in that case i dont know since c# is not my "native" programming language
0
ok