Skip to main content

Write an Algorithm to add two numbers

Description

This algorithm is a simple set of instructions to add two numbers. It begins by declaring three containers (variables) to store values - n1, n2, and SUM. It then asks the user for two numbers, adds them together, and displays the result. Finally, it signals the end of the process.

Algorithm
Step 1 → START
Step 2 → Declare three variables n1, n2 and SUM
Step 3 → Read (input) two numbers and store in n1 & n2 respectively
Step 4 → Add n1&n2 and store result in SUM. i.e. SUM = n1 + n2
Step 5 → Display (output) result i.e. SUM
Step 6 → STOP

What does this mean ?

  • Step 1: START. This marks the beginning of the algorithm.
  • Step 2: Declare three variables n1, n2, and SUM. These are containers to hold values.
  • Step 3: Read (input) two numbers and store in n1 & n2 respectively. Get numbers from the user and store them in n1 and n2.
  • Step 4: Add n1 and n2 and store the result in SUM. Perform addition with the numbers in n1 and n2, and store the result in SUM.
  • Step 5: Display (output) the result, i.e., SUM. Show the result to the user.
  • Step 6: STOP. This marks the end of the algorithm.

Learn more

Reference