Ads

Types of Algorithms

The algorithm and flowchart, classification into 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.


Sequence

The sequence is exemplified by sequence of statements place one after the other – the one above or before another gets executed first. In flowcharts, sequence of statements is usually contained in the rectangular process box.

1. 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: Read\input the Radius r of the Circle
Step2: Area = PI*r*r // calculation of area
Step3: Print Area

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: Read\input the first num1. 
Step3: Read\input the second num2. 
Step4: Sum num1+num2 // calculation of sum 
Step5: Print Sum 
Step6: End 

3. Convert temperature Fahrenheit to Celsius 

Inputs to the algorithm: Temperature in Fahrenheit 
Expected output: Temperature in Celsius 

Algorithm:

Step1: Start
Step 2: Read Temperature in Fahrenheit F
Step 3: C 5/9*(F32)
Step 4: Print Temperature in Celsius: C
Step5: End


     


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

buttons=(Accept !) days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !