Social Icons

Tuesday, September 3, 2013

control structure


Programs written in procedural languages, the most common kind, are like recipes, having lists of ingredients and step-by-step instructions for using them. The three basic control structures in virtually every procedural language are:
  • 1. Sequence—combine the liquid ingredients, and next add the dry ones.
  • 2. Conditional—if the tomatoes are fresh then simmer them, but if canned, skip this step.
  • 3. Iterative—beat the egg whites until they form soft peaks.
Sequence is the default control structure; instructions are executed one after another. They might, for example, carry out a series of arithmetic operations, assigning results to variables, to find the roots of a quadratic equation ax2 + bx + c = 0. The conditional IF-THEN or IF-THEN-ELSE control structure allows a program to follow alternative paths of execution. Iteration, or looping,

No comments:

Post a Comment