What is an Algorithm in Programming Languages Examples

December 23, 2016 0 By Abid

An algorithm is a set step by step instructions to solve a problem or program. A good algorithm always have a starting and ending point. In an algorithm inputs and outputs must be properly defined .  All steps in an algorithm must be clear. An algorithm can’t have syntax code. Instead, the algorithm should be written in a way that it can be used in any programming languages.

Algorithm Examples in Programming

Write an algorithm to subtract two number.

Step 1: Start
Step 2: Declare variables n1, n2 and s. 
Step 3: Read values n1 and n2. 
Step 4: Subtract n2 from n1 and assign the result to s.
Step 5: Display subtraction result. 
Step 6: Stop

Write an algorithm to check email validity by user.

Step 1: Start
Step 2: Declare variable em to store email . 
Step 3: Read email from user and stored in variable em. 
Step 4: Check the read input either it is valid or not.  
Step 5: Not valid go back to step 3. 
Step 6: Stop