Thursday 22 March 2018

Pseudo Codes for Basic Logic (Control) Structure

Pseudocode is a compact and informal high-level description of a computer programming algorithm.
  Pseudo-code typically omits details that are not essential for human understanding of the algorithm such as variable declaration, system-specific code and subroutines.
   The purpose of using pseodocode is that it is easier for humans to understand than conventional programming language code.

Sequence Logic
   Sequence logic is used for performing instruction one after another in sequence. The logic flow of pseudo code is from top to bottom.

Selection Logic
  1. If-else
         Selection logic also known as decision logic is used for making decision.It is also called as decision logic.
       It is used for selecting the proper path out of two or more alternative paths in program logic.Selection logic is depicted as an IF.....THEN.....ELSE or on IF.....THEN or a case structure.
    The IF......THEN......ELSE construct says that if condition is true then 
            do process-I else (if condition is not true) do process-II.

  If we simply want do decide if a process is to be performed or not the IF.....THEN structure is used this structure says that if condition is true then do process-I and if it is not true then skip over process-I.

    The case structure is multiple way selection logic structure.The CASE structure indicates that if the value of type is equal to type I execute process-I if it equal to type II executes process II if it equals to type 3 execute process 3 if so on.
                       Fig: Flowchart for 'CASE' selection structure

Iteration (or Looping) Logic

    The looping structures in C are-
                 While loop
                 For loop
                 Do -while loop
  Iteration logic is used to produce loops in program logic when one or more instruction may be executed several times depending on some condition.
    In case Do-WHILE the looping will continue as long as the condition is true the looping steps when the condition is not true.
    Important : Do-while loop is useful when we want the statements within the loop must be executed at least once.
                        Fig: Flowchart for DO-WHILE iteration structure

In case of REPEAT.....UNTIL : The looping continues until the condition becomes true. That is the execution of the statement  within the loop is repeated as long as the condition is not true.


Post a Comment

Popular Posts


AI (1) Android (23) AngularJS (1) Assembly Language (2) book (1) Books (36) C (76) C# (12) C++ (82) Course (51) Coursera (8) Cybersecurity (4) Data Science (19) Data Strucures (4) Deep Learning (4) Django (1) Downloads (3) edx (1) Engineering (13) Excel (1) flutter (1) FPL (17) Google (10) Hadoop (1) HTML&CSS (41) IBM (1) IS (25) Java (90) Leet Code (4) Machine Learning (2) Meta (2) Pandas (2) PHP (20) Projects (26) Python (585) Python Coding Challenge (40) R (69) Selenium Webdriver (2) Software (15) SQL (28)


Person climbing a staircase. Learn Data Science from Scratch: online program with 21 courses