5 - Define algorithm. Explain how to prepare algorithm with an example.

Discuss Structure of Flow Chart and properties as well as types of algorithm. Or Define algorithm. Explain how to prepare algorithm with an example.



Algorithm:

  • An algorithm is a step-by-step procedure for solving a problem in a finite number of steps.
  • It is written in our descriptive language.

To prepare an algorithm:


Step 1: Define input for our algorithm.

· Many algorithms take in data to be processed, for example: to calculate the sum of two numbers, input are two numbers.

Step 2: Define the variables.

· The algorithms variable allows us to use it for more than one place. We can define the two variables for the 1st number and 2nd number as num1 and num2.

Step 3: Outlines the Algorithm operations.

· Use input variables for the computation purpose.

Step 4: Output the results of our algorithm operations.

· In case of a sum of two numbers, output is the addition of two variables stored in the variable “sum”.



Example:


Step 1: Start.
Step 2: Declare num1, num2, sum.
Step 3: Enter the value of num1 and num2.
Step 4: sum = num1 + num2.
Step 5: Display sum.
Step 6: Stop.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.