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.

Switch-case
    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
                 Repeat-until
  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.

0 Comments:

Post a Comment

Popular Posts

Categories

AI (27) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (112) C (77) C# (12) C++ (82) Course (60) Coursera (176) coursewra (1) Cybersecurity (22) data management (11) Data Science (85) Data Strucures (6) Deep Learning (9) Django (6) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (5) flutter (1) FPL (17) Google (18) Hadoop (3) HTML&CSS (46) IBM (25) IoT (1) IS (25) Java (92) Leet Code (4) Machine Learning (43) Meta (18) MICHIGAN (4) microsoft (3) Pandas (3) PHP (20) Projects (29) Python (719) Python Coding Challenge (155) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (2) Software (17) SQL (40) UX Research (1) web application (8)

Followers

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