how many times the code executes ?

Mar 20, 2014 at 2:12am
how many times will this executes >

1
2
3
4
5
6
int j = 5;
int i = 100;
while (i<j)
{
i--;
}
Mar 20, 2014 at 2:29am
When will 100 ever be less than 5?

Edit

Anyways why can't you compile it and output i? :P
Last edited on Mar 20, 2014 at 2:29am
Mar 20, 2014 at 7:32am
tried to compile got 100,
does i-- affect the execution ?
so it would be 95 right ?
Mar 20, 2014 at 7:38am
If you did what I said and got 100 as a result then remember the initial value was 100 so it would mean that 100(start) - 100(end) = 0 which means it iterated 0 times. It never executes. As I mentioned earlier 100 will never be less than 5 and that is the only time it will execute.
Topic archived. No new replies allowed.