about --n
Can any briefly tell that the difference between --n and n--
another thing
n=5
while (--n>0)
{if(n==2)
cout<<n;
break;
}
cout<<"endloop";
what would be the output of about program and how times the loop runs?
why do you ask something that you can try on compiler yourself?
--n means decrement n before using it in an expression.
n-- means decrement n after using it in an expression.
In your example, the first time through the loop n is decremented from 5 to 4 before comparing to zero.
what would be the output of about program and how times the loop runs?
|
Try it and find out.
Topic archived. No new replies allowed.