Hi,
I was watching the video in programming fundamentals-1 on while and do while loop. Here, they is a mention of an example wherein, we can go and increment until the variable x’s value is 10.
Its like this
int x = 0;
while(x!=10)
{
//Whatever statements go here
x = x+1;
}
My query is, couldn’t we do the same thing with (x<10)? Is there a reason to choose one option over the other, and if so, if for example I want to run a loop from 0 to 10, should I prefer (x!=10) or (x<10), with an increment of x=x+1. Would appreciate your guidance on this, as I got confused on why we used (x!=10) rather than (x<10) which could be an alternative? Thanks!
