Rules for writing an algorithm

Qualities of a good algorithm

  1. Inputs and outputs should be defined precisely.
  2. Each steps in algorithm should be clear and unambiguous.
  3. Algorithm should be most effective among many different ways to solve a problem.
  4. An algorithm shouldn't have computer code. Instead, the algorithm should be written in such a way that, it can be used in similar programming languages.
Write an algorithm to add two numbers entered by user.
Step 1: Start
Step 2: Declare variables num1, num2 and sum. 
Step 3: Read values num1 and num2. 
Step 4: Add num1 and num2 and assign the result to sum.
        sumnum1+num2 
Step 5: Display sum 
Step 6: Stop
 

Comments

Popular posts from this blog

NASM: program to find largest number from an array of 32-bit numbers(hard-coded)

Rules for drawing a FLOWCHART