Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3395052
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:14:38+00:00 2026-05-18T04:14:38+00:00

I was a Computer Science Student. But i didn’t coded much. For loops are

  • 0

I was a Computer Science Student. But i didn’t coded much. For loops are quite simple to me and if it was nested for loop, my head starts to spin.

Tell me how can i master in nested for loops. Where shall i start to practice?

Once my class staff told us that any application which uses less for loops is the most efficient one. Is that real?

Suggest me any book or paper on for loops or links!!

deceze:How about you give us an example nested loop and tell us what you don't understand about it?

I cannot able to explain it fully. Whenever i start to think of a function which needs 2 for loops(nested), firts two iterations goes smooth. After that if i add any other calculation inside the inner loop, after a second its all gone. I cannot continue. So, then i have to run the loop in PC as smaller one, then i build it to a fully functional one.

Ok, Leave me. What you all do, i mean, how you start if you have to build a function which needs more than 2 nested for loops.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:14:39+00:00Added an answer on May 18, 2026 at 4:14 am

    Suggest me any book or paper on for loops or links!!

    To solidify your understanding of 2 for loops, you can try practicing at http://www.codingbat.com/java – moreover, there’s instant and (mostly) thorough grading!
    String-3 or Array-3 problems can use 2 for loops.

    If you have a 2D array, and you need to reach all the indices, you could use 2 for loops. Thus, similarly, if you have a 3D array, you can use 3 nested loops. Remember that the inside of a loop ends before the outside — so if you have 2 loops, the inside code would loop for the amount of time the inner loop specifies, for the number of times that the outside loop specifies. You can draw a diagram:

    for(int i = 0; i < 2; i++) {
      for(int j = 0; j < 2; j++) {
        for(int k = 0; k < 2; k++) {
          //do something
        }
      }
    }
    

    The visual representation:

    i:      0-----------1
            |           |
    j:   0-----1     0-----1
         |     |     |     |
    k: 0---1 0---1 0---1 0---1
    

    If I assign letters:

    i:      A-----------B
            |           |
    j:   C-----D     E-----F
         |     |     |     |
    k: G---H I---J K---L M---N
    

    with X1 being the first part of X (before the nested for loop) and X2 the second part (after the nested for loop), the order of execution is:

    A1, C1, G, H, C2, D1, I, J, D2, A2, B1, E1, K, L, E2, F1, M, N, F2, B2

    So you don’t need to picture n-dimensional arrays when you’re looking at for loops.

    Once my class staff told us that any application which uses less for loops is the most efficient one. Is that real?

    If your for loop involves calculating a value like a formula, it would be faster and probably more efficient to just plug things into the formula. But generally the slowest Big O algorithm would affect the program’s efficiency the most – so a stand-alone for loop that depends on n (as its stop condition) wouldn’t slow down a program much more if it also had nested for loops that depend on n.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a computer science student therefore I do not know that much. I
I am a computer science student currently doing an internship. My boss has asked
I'm an undergrad Computer Science student and studying online. There is a lot of
I'm a computer science student finishing up my second semester of programming classes. I've
So I am a first year computer science student, for on of my final
I am a newbie Computer Science high school student and I have trouble with
I am a student of Computer Science and have learned many of the basic
I am a college student getting my Computer Science degree. A lot of my
I am an almost-graduating computer science student, and throughout my coding career, I've found
I'm a first year computer science student. We are currently programming in java and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.