which is more efficient of these two
FOR LOOPS
for(int i=0;i<10;i++);
for(int i=0;i<10;++i);
Post increment is less efficient that Pre because in former the value is first updated and then a temporary variable having the previous value is returned. See this.
Anyways for(int i=10; i>0; --i) is the most efficient this is more efficient bcoz in this case ur comparing i with 0 rather than pre stored value(10) which takes some more operations wher as comparision with 0 can be easily done by comparing with a logical value 0.
Saturday, December 30, 2006
More Efficient
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment