Subj : Re: which for loop is better? To : comp.programming.threads From : ssam_iit Date : Fri Mar 25 2005 12:01 am I should've elaborated the problem. Here it goes : for the same number of total iterations(100*1000 in this example) in nested-for-loops, is it more effective to have the outer for loop iterate more than the inner one (case 2), or the other way around (case 1)? David Hopwood wrote in message news:... > sam wrote: > > Hi, > > which one of the following codes in C would you prefer to print > > those "hello"s and why? > > int i,j; > > 1) for(i=0;i<=99;i++) > > for(j=0;j<=999;j++) > > printf("hello"); > > > > 2) for(i=0;i<=999;i++) > > for(j=0;j<=99;j++) > > printf("hello"); > > As if it matters. What a stupid question, teaching people to micro-optimize > without thinking about whether it can possibly lead to any difference in > perceptible performance. Whoever set this homework question should be > ashamed of themselves. .