true @ billy j is only incrementing and not being evaluated for the loop.
try this
main()
{
int i, j;
for (i=0, j=1; i<j; i++, j++)
printf("%d - %d = %d\n", j, i, j - i);
return 0;
}
On 6/22/09, Billy <
billyx5@gmail.com> wrote:
i < 8 is the condition being evaluated so the moment it returns true (when i
== 7) thats it. j has no influence on the evaluation of this condition. its
same as if you had done
main()
{
int i, j;
for (i=0, j=1; i<8; i++)
{
printf("%d - %d = %d\n", j, i, j - i);
*j++;*
}
return 0;
}
-Billy
2009/3/22 Rahim Kara <rahim@applecentre.co.ke>
It's a basic question and i'm sure alot of you can answer this but i'm
still a bit sure. Take a look at the code below.
#include <stdio.h>
main()
{
int i, j;
for (i=0, j=1; i<8; i++, j++)
printf("%d - %d = %d\n", j, i, j - i);
return 0;
}
Now the results yielded are
1 - 0 = 1
2 - 1 = 1
...
8 - 7 = 1
i'd like to know what the delimiting factor here is, i.e. considering i've
not set a loop limit for j, what's stopping my calculation from being as
follows..
148 - 8 = 0
as an example though from my understanding, it should present an infinite
loop.
I\ve been pondering this a while, thought i'd get some Guru's out there to
help out with my understanding of this.
Rahim.
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
Other services @ http://my.co.ke
Other lists
-------------
Skunkworks announce:
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce
Science - http://lists.my.co.ke/cgi-bin/mailman/listinfo/science
kazi - http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.kehttp://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
Other services @ http://my.co.ke
Other lists
-------------
Skunkworks announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce
Science - http://lists.my.co.ke/cgi-bin/mailman/listinfo/science
kazi - http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general