How to write algorithms in programming languages

Author: John Stephens
Date Of Creation: 26 January 2021
Update Date: 29 June 2024
Anonim
How to write an Algorithm | DAA
Video: How to write an Algorithm | DAA

Content

This article shows you how to write algorithms for any programming language. Today, programming languages ​​play a very important role in the real world and are used to develop useful applications. If you want to write code, the first thing to do is design the algorithm.

Steps

  1. Remember that an algorithm is a step-by-step process.

  2. Depending on the programming language, you need to insert syntax (syntax) where it is needed.
  3. Begin.

  4. Insert variables and how to use them.
  5. If they are any loops try to come up with sub numbered lists.

  6. Attempted to return the step number if the loop or condition is not satisfied.
  7. Use the jump command to switch from one statement to another.
  8. Avoid generating unwanted raw data in the algorithm.
  9. Defines the expressions (expressions).
  10. Use the break and stop statements to end the process. advertisement

Method 1 of 1: Sign in

  1. Ask users to enter information.
  2. Check if the entered password and username match with the information stored in the database or not.
  3. If true, set up session and direct your users to a successful login page.
  4. If false, generates an error line, directing the user back to the login page and asking the user to re-type the correct information.
  5. Exit. advertisement

Advice

  • Remove unnecessary comments.
  • Use logic accordingly
  • Use fast computation iterations
  • Create a small algorithm
  • Make the algorithm efficient
  • Plan clearly before writing the algorithm

Warning

  • Time and space complexity checks
  • Don't forget to terminate, otherwise, the code will not work as expected