# Algorithm | Algorithm Design Techniques

• Algorithm is a step by step sequence of instruction to solve a particular problem or task.
• The algorithm can be defined as a well-defined sequence of instructions to solve a particular task.

## Algorithm Design Techniques

1. Start
2. Input and output should be defined clearly.
3. The algorithm should be effective to solve a particular task or problem
4. An algorithm shouldn't include computer code in it

## Algorithm explanation in Real Life

• An algorithm can be compared to real life. Suppose You are going to shop for buying sweets. Here You will take an initiative to travel to the shop. That means you need a start here. Next, you will take your vehicle. Here checking the condition of the vehicle is ok or not. If yes, you will start your travel. Check your shop. Ask your product. If you got the product, you will return home.
• In the above real-life example, your task is buying sweets. For buying the sweets, you have to take some steps. Actually here algorithm can be defined as these step by step actions or steps to complete your task.

### write an algorithm for buying sweets

Step1: Start
Step2: Initiate to travel to shop
Step3: Checking your condition to go to the shop. If yes go to step 4 else go to step 3
Step4: Find the shop
Step7: Stop

• Same as you can write an algorithm for a program on the computer. Before any programming, Just imagine what you are going to do. The algorithm can be defined as the imagination of steps for doing a particular task.
• Consider you have to solve some of two numbers. Before you are going to programming, You should think about how you can solve this problem.

### Write an algorithm to find the sum of two numbers

Step1: Start
Step2: Declare the variables number1, number2, and sum
Step3: Input the numbers number1, number2
Step4: sum <- number1 + number2
Step5: Print the value of the sum
Step6: Stop

## Examples of Algorithm

1. Write an algorithm to find the largest of two numbers
2. Write an algorithm to find the largest of three numbers
3. Write an algorithm to find factorial of a number of an entered number.
4. Write an algorithm to find Fibonacci series up to a 100.

##### Top Questions
 explode and implode function in PHP Structures in C Introduction to C Programming Object Oriented Programming Differentiate between require() and include() function in PHP? Differences between GET and POST What is PEAR in PHP? What is the function of git log? Two Dimensional Arrays in C Programming Scope rules and functions in C How to create and load view in codigniter? Structure of a C Program What is Yii Framework | Advantages of Yii over other frameworks | Different versions of Yii PHP Arrays HTTP Status Codes List for REST API What is the difference between git diff and git status? printf() and scanf() function in C Programming History of PHP What is the differene between require(), require_once(), include() and include_once() Break Statement In C