Abstract

This chapter discusses repetitive statements; iterative, or repetition, allows the looping of a set of statements. There are three forms of iteration: for loop, repeat..until, and while. Many tasks within a program are repetitive, such as prompting for data, counting values, and so on. The for loop allows the execution of a block of code for a given control function or a given number of times. In C the do..while () statement is similar in its operation to while ()except that it tests the condition at the bottom of the loop. The repeat..until () in Pascal is also similar to the while() statement but unlike while() the loop quits when the associated condition is true. These loops thus allow statement block to be executed at least once. Often a user is asked to repeat the program once it has finished calculating values. This is sometimes done by asking the user if they want to repeat (or continue) the program. If the user enters a 'y' character then the program is repeated, else a 'n' character will exit the program.

Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call