<< Chapter < Page Chapter >> Page >

An algorithm should be (at least)

–complete (i.e. cover all the parts)

–unambiguous (no doubt about what it does)

–finite (it should finish)

3. code the solution

This step consists of translating the algorithm into a computer program using a programming language.

4. test and correct the program

This step requires testing of the completed computer program to ensure that it does, in fact, provide a solution to the problem. Any errors that are found during the tests must be corrected.

Figure below lists the relative amount of effort that is typically expended on each of these four development and design steps in large commercial programming projects.

Four development and design steps in commercial programming projects

Phase ii: documentation

Documentation requires collecting critical documents during the analysis, design, coding, and testing.

There are five documents for every program solution:

  • Program description
  • Algorithm development and changes
  • Well-commented program listing
  • Sample test runs
  • User’s manual

Phase iii: maintenance

This phase is concerned with the ongoing correction of problems, revisions to meet changing needs and the addition of new features. Maintenance is often the major effort, and the longest lasting of the three phases. While development may take days or months, maintenance may continue for years or decades.

Algorithms

An algorithm is defined as a step-by-step sequence of instructions that describes how the data are to be processed to produce the desired outputs. In essence, an algorithm answers the question: “What method will you use to solve the problem?”

You can describe an algorithm by using flowchart symbols. By that way, you obtain a flowchart which is an outline of the basic structure or logic of the program.

Flowchart symbols

To draw flowchart, we employ the symbols shown in the Figure below.

Flowchart symbols

The meaning of each flowchart symbol is given as follows.

Description of flowchart symbols

To illustrate an algorithm, we consider the simple program that computes the pay of a person. The flowchart for this program is given in the Figure below.

Note: Name, Hours and Pay are variables in the program.

A sample flowchart

Algorithms in pseudo-code

You also can use English-like phases to describe an algorithm. In this case, the description is called pseudocode. Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode has some ways to represent sequence, decision and repetition in algorithms. A carefully prepared pseudocode can be converted easily to a corresponding C++ program.

Example: The following set of instructions forms a detailed algorithm in pseudocode for calculating the payment of person.

Input the three values into the variables Name, Hours, Rate.

Calculate Pay = Hours Rate.

Display Name and Pay.

Loops in algorithms

Many problems require repetition capability, in which the same calculation or sequence of instructions is repeated, over and over, using different sets of data.

Example 1.1. Write a program to do the task: Print a list of the numbers from 4 to 9, next to each number, print the square of the number.

The flowchart for the algorithm that solves this problem is given in Figure below. You will see in this figure the flowchart symbol for decision and the flowline that can connect backward to represent a loop.

Flowcharts of example 1.1

Note:

  1. In the flowchart, the statement

NUM = NUM + 1

means “old value of NUM + 1 becomes new value of NUM ”.

The above algorithm can be described in pseudocode as follows:

NUM = 4

do

SQNUM = NUM*NUM

Print NUM, SQNUM

NUM = NUM + 1

while (NUM<= 9)

You can compare the pseudo-code and the flowchart in Figure above to understand the meaning of the do… while construct used in the pseudo-code.

Flowchart versus pseudocode

Since flowcharts are inconvenient to revise, they have fallen out of favor by programmers. Nowadays, the use of pseudocode has gained increasing acceptance.

Only after an algorithm has been selected and the programmer understands the steps required can the algorithm be written using computer-language statements. The writing of an algorithm using computer-language statements is called coding the algorithm, which is the third step in our program development process.

Questions & Answers

differentiate between demand and supply giving examples
Lambiv Reply
differentiated between demand and supply using examples
Lambiv
what is labour ?
Lambiv
how will I do?
Venny Reply
how is the graph works?I don't fully understand
Rezat Reply
information
Eliyee
devaluation
Eliyee
t
WARKISA
hi guys good evening to all
Lambiv
multiple choice question
Aster Reply
appreciation
Eliyee
explain perfect market
Lindiwe Reply
In economics, a perfect market refers to a theoretical construct where all participants have perfect information, goods are homogenous, there are no barriers to entry or exit, and prices are determined solely by supply and demand. It's an idealized model used for analysis,
Ezea
What is ceteris paribus?
Shukri Reply
other things being equal
AI-Robot
When MP₁ becomes negative, TP start to decline. Extuples Suppose that the short-run production function of certain cut-flower firm is given by: Q=4KL-0.6K2 - 0.112 • Where is quantity of cut flower produced, I is labour input and K is fixed capital input (K-5). Determine the average product of lab
Kelo
Extuples Suppose that the short-run production function of certain cut-flower firm is given by: Q=4KL-0.6K2 - 0.112 • Where is quantity of cut flower produced, I is labour input and K is fixed capital input (K-5). Determine the average product of labour (APL) and marginal product of labour (MPL)
Kelo
yes,thank you
Shukri
Can I ask you other question?
Shukri
what is monopoly mean?
Habtamu Reply
What is different between quantity demand and demand?
Shukri Reply
Quantity demanded refers to the specific amount of a good or service that consumers are willing and able to purchase at a give price and within a specific time period. Demand, on the other hand, is a broader concept that encompasses the entire relationship between price and quantity demanded
Ezea
ok
Shukri
how do you save a country economic situation when it's falling apart
Lilia Reply
what is the difference between economic growth and development
Fiker Reply
Economic growth as an increase in the production and consumption of goods and services within an economy.but Economic development as a broader concept that encompasses not only economic growth but also social & human well being.
Shukri
production function means
Jabir
What do you think is more important to focus on when considering inequality ?
Abdisa Reply
any question about economics?
Awais Reply
sir...I just want to ask one question... Define the term contract curve? if you are free please help me to find this answer 🙏
Asui
it is a curve that we get after connecting the pareto optimal combinations of two consumers after their mutually beneficial trade offs
Awais
thank you so much 👍 sir
Asui
In economics, the contract curve refers to the set of points in an Edgeworth box diagram where both parties involved in a trade cannot be made better off without making one of them worse off. It represents the Pareto efficient allocations of goods between two individuals or entities, where neither p
Cornelius
In economics, the contract curve refers to the set of points in an Edgeworth box diagram where both parties involved in a trade cannot be made better off without making one of them worse off. It represents the Pareto efficient allocations of goods between two individuals or entities,
Cornelius
Suppose a consumer consuming two commodities X and Y has The following utility function u=X0.4 Y0.6. If the price of the X and Y are 2 and 3 respectively and income Constraint is birr 50. A,Calculate quantities of x and y which maximize utility. B,Calculate value of Lagrange multiplier. C,Calculate quantities of X and Y consumed with a given price. D,alculate optimum level of output .
Feyisa Reply
Answer
Feyisa
c
Jabir
the market for lemon has 10 potential consumers, each having an individual demand curve p=101-10Qi, where p is price in dollar's per cup and Qi is the number of cups demanded per week by the i th consumer.Find the market demand curve using algebra. Draw an individual demand curve and the market dema
Gsbwnw Reply
suppose the production function is given by ( L, K)=L¼K¾.assuming capital is fixed find APL and MPL. consider the following short run production function:Q=6L²-0.4L³ a) find the value of L that maximizes output b)find the value of L that maximizes marginal product
Abdureman
types of unemployment
Yomi Reply
What is the difference between perfect competition and monopolistic competition?
Mohammed
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Programming fundamentals in c++. OpenStax CNX. Jul 29, 2009 Download for free at http://cnx.org/content/col10788/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Programming fundamentals in c++' conversation and receive update notifications?

Ask
Saylor Foundation
Start Quiz
Royalle Moore
Start Quiz
Edgar Delgado
Start Test
Heather McAvoy
Start Quiz
Eric Crawford
Start Quiz
Danielle Stephens
Start Quiz