Algorithm Examples | Algorithm Simple Example | Factorial Algorithm

In this article algorithm examples we give the algorithm simple examples also conditional and lopping related examples like addition of two numbers, area of circle etc.

Algorithm Examples:

  1. Write an algorithm to find addition of two numbers entered by the user

Step 1: Start

Step 2: Declare variables say n1, n2 and sum.

Step 3: Read values n1 and n2.

Step 4: Perform the addition of n1 and n2 and assign the result to sum.

Step 5: Display sum

Step 6: Stop

  1. Write an algorithm to find area of rectangle (Area of rectangle=length * breadth)

Step 1: Start

Step 2: Declare variables say length, breadth and area.

Step 3: Read values length and breadth

Step 4: Multiply length and breadth and assign the result to area.

Step 5: Display area

Step 6: Stop

  1. Write an algorithm to find area of circle. (Area of circle=PI*r*r)

Step 1: Start

Step 2: Declare variables say radios and area.

Step 3: Read values radios

Step 4: Multiply 3.142 into radios into radios and assign the result to area.

Step 5: Display area

Step 6: Stop

Algorithm Examples:

  1. Write an algorithm to find Simple interest. [Simple Interest= (p*n*r)/100]

Step 1: Start

Step 2: Declare variables say p, n, r and SI.

Step 3: Read values p, n and r.

Step 4: Multiply by p into n into r and divided by 100 and assign the result to SI.

Step 5: Display SI

Step 6: Stop

  1. Write an algorithm to find the largest number among two numbers

 Step 1: Start

Step 2: Declare variables say p and q.

Step 3: Read values p and q.

Step 4: if p is greater than q then goto step 7 otherwise goto next step.

Step 5: if q is greater than p then goto step 8 otherwise goto next step.

Step 6: Display both are equal and goto step 9.

Step 7: Display p is the largest number and goto step 9.

Step 8: Display q is the largest number.

Step 9: Stop

  1. Write an algorithm to find the largest number among three different numbers

 Step 1: Start

Step 2: Declare variables say p, q and r.

Step 3: Read different values p, q and r.

Step 4: if p is greater than q and p is greater than r then goto step 7 otherwise goto next step.

Step 5: if q is greater than r then goto step 8 otherwise goto next step.

Step 6: Display r is the largest number and goto step 9.

Step 7: Display p is the largest number and goto step 9.

Step 8: Display q is the largest number.

Step 9: Stop

Algorithm Examples:

  1. Write an algorithm to find the odd and even number entered by user

 Step 1: Start

Step 2: Declare variables say n.

Step 3: Read values n.

Step 4: if n is divided by 2 and we get the result like remainder is zero then goto step 6 otherwise goto next steps.

Step 5: Display given number is Odd and goto step 7

Step 6: Display given number is Even.

Step 7: Stop

  1. Write an algorithm to find leap year entered by user

 Step 1: Start

Step 2: Declare variables say y.

Step 3: Read values y.

Step 4: if y is divided by 4 and y is divided by 400 we get the result like remainder is zero then goto step 6 otherwise goto next steps.

Step 5: Display given year is not leap year and goto step 7.

Step 6: Display given year is leap year.

Step 7: Stop.

  1. Write an algorithm to find factorial of number entered by user

 Step 1: Start

Step 2: Declare variables say n, fact.

Step 3: Initialize the value fact=1.

Step 4: if n is greater than zero then goto next step otherwise goto step 7

Step 5: Multiply fact into n and assign the result to fact.

Step 6: perform n is decreased by one and goto step 4

Step 7: Display fact

Step 8: Stop.

Related Link:

Some More: DBMS/ WT/ DMDW

Santosh Nalawade

Work as Assistant Professor and Web Developer.

Leave a Reply

Your email address will not be published. Required fields are marked *