Ask Question

True or False?

The break statement causes a loop to stop the current iteration and begin

the next one.

+4
Answers (1)
  1. 1 January, 01:13
    0
    False.

    The different between break and continue instruction is that with break you exit the loop, and with continue you skip to the next iteration.

    So, for example, a loop like

    for (i = 1; i < = 10; i++) {

    if (i < = 5) {

    print (i);

    } else {

    break;

    }

    }

    will print 1,2,3,4,5, because when i=6 you will enter the else branch and you will exit the loop because of the break instruction.

    On the other hand, a loop like

    for (i = 1; i < = 10; i++) {

    if (i % 2 = = 0) {

    print (i);

    } else {

    continue;

    }

    }

    Will print 2,4,6,8,10, because if i is even you print it, and if i is odd you will simply skip to the next iteration.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “True or False? The break statement causes a loop to stop the current iteration and begin the next one. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers