Professional Documents
Culture Documents
Loops
Reference:
- Sandeep Nagar, Introduction to Scilab For Engineers and Scientists
6.1 Introduction
6.1 Introduction
In this way, a complicated task can be divided into many small parts. This
architecture of programming is called modular programming.
It is the most popular way of programming since it is quite logical, good at
visualizing the problem, and easy to debug.
The most popular way of defining these small sets of instructions is to
define them as functions.
Together, functions and loops break a numerical computation problem into
a series of simpler problems that can be accessed as required.
In this chapter, we will discuss both of these concepts in detail.
6.2 Loops
Loops form an essential part of an algorithm since they perform the tasks
that computers perform best: doing repetitive actions in a very fast manner.
Loops can come in many flavors such as for loop, which repeats certain
tasks over a list of variable values; while loop, which checks a logical
condition before executing a certain task; and if-then-else loop, which
checks a condition and directs the flow of an algorithm.
The loop you choose depends on the problem at hand.
A variety of functions and their usage are described in the following
sections.
Judging their usage critically becomes supremely important because the
looping part of an algorithm consumes most of the execution time.
6.2 Loops
6.2.1 while
6.2.1 while
6.2.1 while
6.2.3 for
6.2.3 for
6.2.3 for
6.2.4 if-elseif-else
6.2.4 if-elseif-else
6.2.4 if-elseif-else
6.2.4 if-elseif-else
6.2.4 if-elseif-else