Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

kanigayan

  • 3 years ago

The following for-loop is an infinite loop. for (int j = 0; j < 1000; i++ ) is this true or false

  • This Question is Closed
  1. Shadowys
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 5

    well, yes, unless that i there is a typo.

  2. kanigayan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    it's false no because this loop will print 999 times , not infinite time no

  3. Shadowys
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 5

    but it's i that increases, not j, right?

  4. kanigayan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    umm not increase no cause it given limit no, when it is infinite j>1000 and j=1000

  5. Shadowys
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 5

    oh...so that i is a typo then. for (int j = 0; j < 1000; i++ ) <--infinite for (int j = 0; j < 1000; j++ ) <--not infinite

  6. kanigayan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    okay then The following for-loop is an infinite loop. for (int j = 0; j < 1000; i++ ) false no

  7. kanigayan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    beacuse it is not infinite loop no

  8. Shadowys
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 5

    (int j = 0; j < 1000; j++ ) is not an infinite loop. yup. look closely though... ^ <--this part here

  9. kanigayan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    okay thanx :)

  10. Shadowys
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 5

    you're welcome :) though you could just try to write a program and see if it works lol :P

  11. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy