
lol, i can see where that's going, i thought about what Billy said as well and it made more sense to me, So in essence, if i set values for i and for j, due respect would be given to both and if only one, then the application would only function using that limit i.e. the query i brought forward where i<8 is the only condition set. That making any sense? On Jun 22, 2009, at 10:03 PM, Chris Mwirigi wrote:
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.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
Rahim Kara | Pro App's Specialist Elite Computers Ltd Apple Premium Reseller Sarit Centre P.O.Box 75289, Nairobi – 00200 KENYA +254 (20) 374 5550 PHONE +254 (20) 375 3509 FAX +254 721 875 042 Safaricom MOBILE +254 734 334 074 Zain MOBILE +254 773 104 250 Orange MOBILE iChat rahim.kara@me.com Mailing List Subscription http://mail.wananchi.com/mailman/listinfo/elitedigitalsolutions