0% found this document useful (0 votes)
18 views

Algorithm in Programming: Amal Alabbad

The document discusses algorithms in programming. It defines an algorithm as a set of well-defined instructions to solve a problem. A good algorithm has precisely defined inputs and outputs, clear and unambiguous steps, and is the most effective way to solve the problem. The document provides examples of algorithms to add two numbers and find the factorial of a number. It notes that an algorithm is not computer code, but rather clear instructions that can be used to write code in different programming languages.

Uploaded by

Kayan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Algorithm in Programming: Amal Alabbad

The document discusses algorithms in programming. It defines an algorithm as a set of well-defined instructions to solve a problem. A good algorithm has precisely defined inputs and outputs, clear and unambiguous steps, and is the most effective way to solve the problem. The document provides examples of algorithms to add two numbers and find the factorial of a number. It notes that an algorithm is not computer code, but rather clear instructions that can be used to write code in different programming languages.

Uploaded by

Kayan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Algorithm in Programming

Amal Alabbad
Algorithm in Programming

In programming, algorithm are the set of well


defined instruction in sequence to solve a
program. An algorithm should always have a
clear stopping point.
Qualities of a good algorithm

 Inputs and outputs should be defined precisely.


 Each steps in algorithm should be clear and
unambiguous.
 Algorithm should be most effective among many
different ways to solve a problem.
 An algorithm shouldn't have computer code. Instead,
the algorithm should be written in such a way that, it can
be used in similar programming languages.
Algorithm Examples

 Write an algorithm to add two numbers entered by user.


Algorithm Examples

 Write an algorithm to add two numbers entered by user.


 Step 1: Start
 Step 2: Declare variables num1, num2 and sum.
 Step 3: Read values num1 and num2.
 Step 4: Add num1 and num2 and assign the result to sum.
 sum←num1+num2
 Step 5: Display sum
 Step 6: Stop
Algorithm Examples

 Write an algorithm to find the factorial of a number entered by user.


Algorithm Examples
 Write an algorithm to find the factorial of a number entered by user.
 Step 1: Start
 Step 2: Declare variables n,factorial and i.
 Step 3: Initialize variables
 factorial←1
 i←1
 Step 4: Read value of n
 Step 5: Repeat the steps until i=n
 5.1: factorial←factorial*i
 5.2: i←i+1
 Step 6: Display factorial
 Step 7: Stop
Note**

Algorithm is not the computer code. Algorithm


are just the instructions which gives clear idea to
you idea to write the computer code.
The end

You might also like