# What is algorithm in programming and write it

The algorithm in programming can be defined as a sequence of activities to be processed for getting the desired output from a given input. Or in other words, it is a formula or set of steps for solving a particular problem. To be an algorithm, a set of rules must be unambiguous and have a clear stopping point. There may be more than one way to solve a problem so there may be more than one algorithm for a problem.

Learn about programming chart or flow chart.

## Algorithm in programming

From the above Data we can say that:
1. Getting specified output is essential after the algorithm is executed.
2. One will get output only if the algorithm stops after a finite time.
3. Activities in an algorithm to be clearly defined in other words for it to be unambiguous.

Before writing an algorithm for a problem, one should find out what is/are the inputs to the algorithm and what is/are expected output after running the algorithm. Now let us take some exercises to develop an algorithm for some simple problems: While writing algorithms we will use the following symbol for different operations:

‘-‘ for Subtraction
‘*’ for Multiplication
‘/’ for Division and
‘ ‘ for assignment.
For example A X*3 means A will have a value of X*3. Lets look at some problems on algorithm.

Problem 1: Write an algorithm to Find the area of a Circle of radius r.

Inputs to the algorithm:

Expected output:
Area of the Circle

Algorithm:

Step2: Area PI*r*r // calculation of area
Step3: Print Area

Problem 2: Write an algorithm to read two numbers and find their sum.

Inputs to the algorithm:
First num1.
Second num2.
Expected output:
Sum of the two numbers.

Algorithm:

Step1: Start
Step4: Sum num1+num2 // calculation of sum
Step5: Print Sum
Step6: End

 Write an algorithm easily

## Type of Algorithms

The algorithm and flowchart, classification to the three types of control
structures. They are:

1. Sequence
2. Branching (Selection)
3. Loop (Repetition)

These three control structures are sufficient for all purposes.

The sequence is exemplified by a sequence of statements place one after the other – the one above or before another gets executed first.

The branch refers to a binary decision based on some condition. If the condition is true, one of the two branches is explored; if the condition is false, the other alternative is taken. This is usually represented by the “if-then” construct in pseudo-codes and programs. Lets see an example.

Problem 3: write an algorithm to find the greater number between two numbers

Step1: Start
Step3: If A greater than B then C=A
Step4: if B greater than A then C=B
Step5: Print C
Step6: End

The loop allows a statement or a sequence of statements to be repeatedly executed based on some loop condition. It is represented by the ‘while’ and ‘for’ constructs in most programming languages, for unbounded loops and bounded loops respectively. Lets see an example.

Problem 4: An algorithm to calculate even numbers between 0 and 99

1. Start
2. I ← 0
3. Write I in standard output
4. I ← I+2
5. If (I <=98) then go to line 3
6. End

## Properties of algorithm

Here is a list of five properties for an algorithm, these properties are:
1) Finiteness: An algorithm must always terminate after a finite number of steps. It means after every step one reaches closer to the solution of the problem and after a finite number of steps, the algorithm reaches to an endpoint.
2) Definiteness: Each step of an algorithm must be precisely defined. It is done by well-thought actions to be performed at each step of the algorithm. Also, the actions are defined as unambiguously for each activity in the algorithm.
3) Input: Any operation you perform need some beginning value/quantities associated with different activities in the operation. So the value/quantities are given to the algorithm before it begins.
4) Output: One always expects output/result (expected value/quantities) in terms of output from an algorithm. The result may be obtained at different stages of the algorithm. If some result is from the intermediate stage of the operation then it is known as an intermediate result and result obtained at the end of the algorithm is known as an end result. The output is expected value/quantities always have a specified relation to the inputs
5) Effectiveness: Algorithms to be developed/written using basic operations. Actually, operations should be basic, so that even they can in principle be done exactly and in a finite amount of time by a person, by using paper and pencil only.

## What are the benefits of investing in logistics application development

Gears surrounding the fulcrum act as a force multiplier. Logistics software solutions are the same for the economy of any country. Just about \$10 trillion is a mammoth market for…

## What Are the Key Steps to Develop a Blockchain App?

By offering distributed, safe, open platforms, blockchain technology has transformed sectors. To guarantee that a blockchain app satisfies the intended functionality and security criteria, development of one calls for meticulous…

## The Role of Full Stack Developers in Modern Web Development

Web development is highly lucrative due to its increased demand. The need for a full stack web developer is growing. Thus, this makes it a sought-after skill. The demand for…

## Role of AI in Accelerating Software Development Processes

Artificial Intelligence has gained huge traction in the last few years. However, the growth has significantly risen due to recent technological advancements. AI’s allied disciplines along with machine learning and…

## Step-by-Step Guide: How to Convert EML Files to HTML

In most cases, EML files are used in various email programs for storing single emails or electronic mail. Though most of the email clients support EML format, you can’t (without…

## Game-Changing Benefits of PWA Development for eCommerce Success

The e-commerce industry has been highly competitive since it was launched. The online shopping trend will stay and there will be no decline.  As per recent statistics, the eCommerce market…