which one should be preferable from the following two nested for loops:
1.
for(i=0;i<100;++i)
{
for(k=0;k<10000;++k)
{
<lines of code>
}
}
2.
for(k=0;k<10000;++k)
{
for(i=0;i<100;++i)
{
<lines of code>
}
}
why?
meetjatin88 0 Newbie Poster
Recommended Answers
Jump to PostSince both are the same, it will probably depend on what "<lines of code>" contains.
Jump to PostExample: Lets say you want to print out a multiplication table that has 10 rows and 5 columns. Rows are numbered 1 through 10 and columns numbered 1 through 5. The value in each column is the row number times the column number.
To print such a table you have …
All 5 Replies
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
meetjatin88 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
vmanes 1,165 Posting Virtuoso
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.