Question:

Difference between structure and unstructure programming langauge?

by  |  earlier

0 LIKES UnLike

between structure and unstructure programming langauge

 Tags:

   Report

2 ANSWERS


  1. A structured language (VB, Pascal, C, C++, C#) has nested logic blocks (if, while, for).  Unstructured languages (Fortran, assembly language, old Basic) doed tests, and depending on test, branches to another line number or address offset within the code.


  2. An "unstructured programming language" is simply one that's not structured. A "structured programming language" is a type of procedural programming language.

    So that leaves two questions. First, what is a procedural programming language? Second, what specifically makes some procedural programming languages structured?

    To the first question, a procedural programming language is the ordinary kind. It's one in which the programmer specifies a sequence of steps and controls directly the order in which they are performed. "First do this. Then, do that. Next, either do this or that depending on something else."

    A procedural explanation for going to bed would say things like: go the bathroom, then brush your teeth, then turn off the light, now if you are not in your pajamas, change.

    You might think there is no other way to program, but there are non-procedural languages. For example, one non-procedural programming language is prolog. It contains constraints rather than steps. Constraints are like "if at any time you have a headache, take aspirin"  or "you can't go to bed with the light on" and don't have any specific order.

    Okay, so what makes a procedural programming language structured? The answer is that structured programming languages don't jump from step to step but instead have logical flows of control that dictate which step occurs when.

    For example, here's an unstructured explanation of how to start your car:

    1) put the key in the ignition.

    2) turn the key

    3) if the car starts, jump to step 8

    4) have we tried more than ten times to start the car, if so, go to step 9

    5) wait ten second

    6) turn the key again

    7) go to step 2

    8) you're done, stop

    9) call a mechanic

    10) stop.

    Notice how when you read it through, you see step 9 and you're kind of puzzled. How did we get here? Why are we doing this? You have to look back to step 4 to see why. That's typical of unstructured programming.

    Here's a structured version:

    put the key in the ignition

    [

    .  turn the key

    .  if the car started, we are done

    .  wait ten seconds

    ] repeat ten times

    call mechanic

    Notice how the structure of the program showed what got repeated? Notice how much clearer it is why we're calling the mechanic? (And notice how you can add in a step you forgot without having to renumber all the steps after it.)

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.