search
Log In
0 votes
112 views
 for( i = n, j = 0; i > 0; i /= 2, j +=i )

Why There is no condition check for j here

in Algorithms 112 views
1

you can declare as  many variables in for as you want. You will check conditions based on your requirement. Here the writer might not want j to act as a control variable governing the number of  times loop runs so he didnt apply any condition check which indeed is perfectly normal.

0
Here loop control variable is “i” , i will stop after logn times . In that time j will increase upto logn.
0
I am not getting how this loop will execute

Pls give one example for any value of n

Please log in or register to answer this question.

Related questions

0 votes
0 answers
1
120 views
for every j != i in {0,....,n-1} is it like for j=0 to n-1; j !=i ; ++j
asked Jul 30, 2018 in Programming iarnav 120 views
3 votes
2 answers
2
0 votes
3 answers
3
458 views
try to print this in one loop itself.i have already done this in two loops(one nested into another).so please try to do in one loop itself. 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25
asked Nov 10, 2014 in Programming sumit kumar 458 views
2 votes
1 answer
4
100 views
#include int main() { int *p, a; p = &a; scanf("%d",p); printf("a = %d *p = %d", a, *p); } a = 32766 *p = 32766 a = 32767 *p = 32767 a = -1219137971 *p = -1219137971 No Output
asked Jul 17, 2016 in Programming Akhil01 100 views
...