# 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
 printf() and scanf() function in C Programming Two Dimensional Arrays in C Programming Get Current Version Of PHP DOCTYPE in HTML Functions in PHP What is PHP? HTTP Status Codes List for REST API Type conversion in C Programming Continue Statement in C Overloading in C++ Arrays in C Programming While loop in C What are sessions in PHP? What is the difference between GET and POST? Break Statement In C What is codigniter Inheritance in C++ How to load public files in laravel PHP Arrays Switch Statement in C