What is algorithm in programming and write it

What is algorithm in programming and write it

SHARE:

Algorithm in programming can be defined as a sequence of activities to be processed for getting 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.

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 Addition
'-' 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:
Radius r of the Circle.
Expected output:
Area of the Circle

Algorithm:
Step1: Readinput the Radius r of the Circle
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
Step2: Readinput the first num1.
Step3: Readinput the second num2.
Step4: Sum num1+num2 // calculation of sum
Step5: Print Sum
Step6: End
algorithm in programming simple guide
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
Step2: Read/input A and B
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.

The algorithm in programming can be learned by practice. Please share this post on Facebook and Twitter and with everyone else. Thank you for reading this post. Ask your questions in the comment section.

COMMENTS

BLOGGER

Related Articles

Name

Android,42,Apps,1,Blogger,24,Blogging,27,Business,19,Computer,71,Development,4,Games,5,Guest,330,Health,13,iOS,9,Marketing,11,Online Tools,1,Programming,25,SEO,66,Social,263,Software,3,Startup,13,Technology,20,Website,13,Wordpress,17,
ltr
item
MindxMaster: What is algorithm in programming and write it
What is algorithm in programming and write it
Algorithm in programming can be defined as a sequence of activities to be processed for getting 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.
https://1.bp.blogspot.com/-0tkmcp6vEss/VrdnW2346aI/AAAAAAAABeI/lQorO_HH7Q0/s1600/Untitled.jpg
https://1.bp.blogspot.com/-0tkmcp6vEss/VrdnW2346aI/AAAAAAAABeI/lQorO_HH7Q0/s72-c/Untitled.jpg
MindxMaster
https://www.mindxmaster.com/2016/02/what-is-programming-algorithms-how-to.html
https://www.mindxmaster.com/
https://www.mindxmaster.com/
https://www.mindxmaster.com/2016/02/what-is-programming-algorithms-how-to.html
true
5332415103371288268
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy