Algorithms can be defined as the set of instructions structuredto solve a problem. It is a step-by-step procedure to solve the problem. These steps are generally written in English to understand them easily and later convert them into computer programs. These steps together are called algorithms.
Let us consider an example, suppose you went shopping and want to know the amount you spent. So, you take out the shopping list and start adding the prices to your calculator.The same work can be done by designing an algorithm that adds your total amount.
2. Assign a variable to each item (item1 name,item2 name,….).
3. Create a variable “total” which will store the total price.
4. Add all the “items” and store it to “total”.
5. Display “total”.