Preparing pseudo code:

Definition:

  •   Pseudo  Code is written using structured English

 Pseudo Code : Some terms are commonly used  to represent  the various actions   for (Input- data,  Output data,Calculation,Addition,Subtraction ,initialization,respectively)

  • Inputting data terms:(INPUT,GET,READ),
  • Outputting data terms:(OUTPUT,PRINT,DISPLAY)
  • Calculation                     :(COMPUTE,CALCULATE)
  • Increment                       :(INCREMENT)
  • Arithmetic Operation    :(ADD,SUBTRACT,INITIALIZE)

 

Rules of pseudo code:

  1.                  Keywords are written in CAPITALS
  2.                   Basic Keywords Come in pairs for every BEGIN  there is an END
  3.                   Indenting to used to show the STRUCTURE
  4.                    Name of subprograms are UNDERLINED

 

 

The Control Structures:

                           1.Sequence, 2.Selection, 3.Iteration   are also while writing the pseudo code

1.Sequence Control Structures:

         -<Book Content> The Sequence structure is simply a sequence of steps to be executed in linear order<Book Content>

Basic Syntax :

 Step1:

Step2:

Step3:

:

:

Example of sequence pseudo code:

                Step1:        BEGIN

                Step2:          GET 2 numbers

                Step3:          STORE in num1 and num2

                Step4:          CALCULATE(num1+num2)

                 Step5:          OUTPUT(sum)

                  Step6:          END

2. Selection Control Structures:

          -<Book Content> There are TWO MAIN Selection Construction – IF-STATEMENT and CASE-STATEMENTS condition true then THEN part is executed  other wise ELSE part is executed <Book Content>

Example synatax:

Using IF -ELSE statement

        IF(condition)THEN

                      statement(s)1

      ELSE

                       statement(s)2

       ENDIF

Using IF Statement

          IF(condition)THEN

                           Statement(s)

           ENDIF

Using Switch statement

         CASE EXPRESSION OF

           Condition1: Statement1

           Condition2: Satement2

                  :

                 :

           Condition:Statement N

    OTHERS: Default Statement (s)

3.Iteration Control Structures:

                 Using WHILE Condition:

                        WHILE(condition)

                         statement 1

                         statement 2

                                 :

                          END

                 Using DO-While Condition:

                       DO

                        statement 1

                         statement 2

                           :

                         WHILE(condition)

Example of Pseudo Code:

Find Product of any two numbers:

                                      READ values of A and B

                                      COMPUTE c by multiplying A with B

                                       PRINT result C

                                       Stop

Find the maximum of any three numbers:

                                      READ values of A ,B,C

                                      IF A is greater than B THEN

                                                   ASSIGN A to MAX

                                        ELSE

                                                   ASSIGN B to MAX

                                       IF MAX is greater than C THEN

                                       PRINT MAX  is Greatest

                                       ELSE

                                        PRINT C is Greatest

                                        STOP

Find some of

Leave a comment