All modern programming languages implement the structured pr

All modern programming languages implement the structured programming constructs, Provide a detailed examples from three programming languages that show structured programming constructs.

Solution

Answer:

Structured programming languages:

A programming language is called as structured programming language if it uses sequence, repetition, selection, subroutines and block routines. The use of goto is avoided.

Examples of three programming languages:

Visual Basic:

Visual Basic is a structured-programming language as it supports the structured concepts.

Sequence:

A code block is executed orderly in that order thy have written.

Eg:

x=11;

y=6;

w=x+y;

WriteLine(w);

Repetition or iteration:

A code is block executed repeatedly until certain condition is true. The repetition is done by using while, for, Do…While loops.

While condition

     Statements

End While

Eg:

kk=1

While kk<=10

          WriteLine(kk)

          kk = kk+1

End

Selection:

It uses a blocks of codes to perform the task. One/more code-blocks are implemented based on the circumstance. The selection-statement is achieved by using “if-else”, nested if-else, “switch”.

Eg:

            If number Mod 2=0

          WriteLine(“Even number”)

     Else

          WriteLine (“Odd Number”)

     End If

C

C is also a structured-programming languages as it uses structured programming concepts such as loops, “if-else”, “switch”, functions and blocks to the perform the required task.

SEQUENCE:

Blocks of code are executed in order.

The addition of 2 numbers can be done by using the sequence-statements,

a=10;

b=5;

c=a+b;

ITERATION OR REPETITION:

Repeat a code block until definite condition is met. The repetition statements here are while, for, do-while.

To print numbers from 1--10, the following repetition-statement can be used,

i=1;

while(i<=10)

{

     printf(“%d\ ”, i);

     i++;

}

SELECTION:

A code-block is implemented based on the fulfilling-condition. The if-else, nested if-else, switch are used in this for achieving the selection control.

To print a number is even or odd the following selection statement can be used.

if(number%2==0)

{

     printf(“The number is EVEN”);

}

else

{

     printf(“The number is ODD”);

}

Ada:

            Sequence:

            The codes are executed in that order they have written.

            Eg:

                        Ada.Text_IO.Put_Line(aa);

          Ada.Text_IO.Put_Line(bb);

            Repetition or iteration:

A code block is repeated until certain condition is true. Ada uses “for, while, loop-exit” to achieve the repetition structure.

            Eg:

                        for kk in 1 .. 10 loop

              Ada.Text_IO.Put(kk);

          end loop;

            Selection:

            A code-block is implemented based on the fulfilling-condition.

            Eg:

                        if aa>bb then

              Ada.Text_IO.Put_Line(“A is greater”);

          else

              Ada.Text_IO.Put_Line(“B is greater”);

          end if;

                                               

        

All modern programming languages implement the structured programming constructs, Provide a detailed examples from three programming languages that show structu
All modern programming languages implement the structured programming constructs, Provide a detailed examples from three programming languages that show structu
All modern programming languages implement the structured programming constructs, Provide a detailed examples from three programming languages that show structu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site