Saturday, 2 February 2013

Pseudo-code


  • Pseudo-code is a tool that can be used to express algorithms more precisely
  • Pseudo-code is a combination of programming code and ordinary English
  • Pseudo-code allows algorithms to be specified precisely without having to worry about programming language syntax
  • There is currently no firmly established standard for Pseudo Code
  • Pseudo-code is not actually executed on a computer, it simply provides a means for programmers to "Think out" their programs before they implement them
  • A carefully prepared pseudo code program can be easily converted to a programming language such as C++ or Java.
  • HOW TO WRITE PSEUDO CODE?
    • Any algorithm will eventually need to have its instructions performed by a computer
    • For this reason the keywords used in Pseudo code are based on the main functions fo a computer.
  • Rules for Pseudo-code
    • INPUT
      • READ get input from a file
      • GET    get input from the keyboard
    • ARITHMETIC / CALCULATIONS
      • +_ * / ( ) =
    • OUTPUT
      • PRINT output to a printer
      • WRITE output to a file
      • DISPLAY output to a monitor
    • STORE
      • SET total_price to 0
      • total_price = cost_price + tax
    • COMPARE
      • IF student is part time THEN ADD 1 to part time ELSE ADD 1 to full time ENDIF
    • REPETITION
      • DOWHILE student_total < 50 READ student_record ADD 1 to student_total ENDDO
      • WHILE student_total < 50 READ student_record ADD 1 to student_total ENDWHILE
  • Examples

No comments:

Post a Comment