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

100 Python Programs for Beginner (53) AI (34) Android (24) AngularJS (1) Assembly Language (2) aws (17) Azure (7) BI (10) book (4) Books (173) C (77) C# (12) C++ (82) Course (67) Coursera (226) Cybersecurity (24) data management (11) Data Science (128) Data Strucures (8) Deep Learning (20) Django (14) Downloads (3) edx (2) Engineering (14) Excel (13) Factorial (1) Finance (6) flask (3) flutter (1) FPL (17) Google (34) Hadoop (3) HTML&CSS (47) IBM (25) IoT (1) IS (25) Java (93) Leet Code (4) Machine Learning (59) Meta (22) MICHIGAN (5) microsoft (4) Nvidia (3) Pandas (4) PHP (20) Projects (29) Python (932) Python Coding Challenge (358) Python Quiz (23) Python Tips (2) Questions (2) R (70) React (6) Scripting (1) security (3) Selenium Webdriver (3) Software (17) SQL (42) UX Research (1) web application (8) Web development (2) web scraping (2)

Followers

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