Back To Course

Business 109: Intro to Computing10 chapters | 84 lessons | 9 flashcard sets

Are you a student or a teacher?

Try Study.com, risk-free

As a member, you'll also get unlimited access to over 75,000 lessons in math, English, science, history, and more. Plus, get practice tests, quizzes, and personalized coaching to help you succeed.

Try it risk-freeWhat teachers are saying about Study.com

Already registered? Login here for access

Your next lesson will play in
10 seconds

Lesson Transcript

Instructor:
*Paul Zandbergen*

Paul has a PhD from the University of British Columbia and has taught Geographic Information Systems, statistics and computer programming for 15 years.

There are several alternative approaches to the programming process, including procedural programming and functional programming. Learn about the differences between these two approaches.

Programming is a creative process carried out by programmers to instruct a computer on how to complete a task. A program is a set of instructions that tells a computer what to do in order to come up with a solution to a particular problem. There are a number of alternative approaches to the programming process. Two very different approaches are procedural programming and functional programming. Each of these two approaches will be described in some detail.

**Procedural programming** uses a list of instructions to tell the computer what to do step by step. Procedural programming relies on procedures, also known as routines. A procedure contains a series of computational steps to be carried out. Procedural programming is also referred to as imperative or structured programming.

Procedural programming is intuitive in the sense that it is very similar to how you would expect a program to work. If you want a computer to do something, you should provide step-by-step instructions on how to do it. Many of the early programming languages are all procedural. Examples of procedural languages include Fortran, COBOL and C, which have been around since the 1960s and 70s.

A common technique in procedural programming is to repeat a series of steps using iteration. This means you write a series of steps and then tell the program to repeat these steps a certain number of times. This makes it possible to automate repetitive tasks.

**Functional programming** is an approach to problem solving that treats every computation as a mathematical function. The outputs of a function rely only on the values that are provided as input to the function and don't depend on a particular series of steps that precede the function.

Functional programming relies heavily on recursion. A recursive function can repeat itself until a particular condition is reached. This is similar to the use of iteration in procedural programming, but now applied to a single function as opposed to a series of steps. Examples of functional programming languages include Erlang, Haskell, Lisp and Scala.

Programming approaches can sound a little bit abstract, so let's look at an example. We'll use the same task and look at how each approach would carry out this task. The task is to calculate Fibonacci numbers. By definition, the first two numbers in a Fibonacci sequence are 0 and 1, and the following numbers are always the sum of the previous two. In mathematical terms, here is what the sequence looks like:

The result is a sequence that looks like this:

0 1 1 2 3 5 8 13 21 34 55 89

Fibonacci numbers are used for a wide range of applications, from describing patterns in nature to the structures of galaxies. So what is the Fibonacci number for *n* = 100? This is exactly the kind of task you want a computer program to do for you. Don't worry too much about understanding the math - the point is that we want a computer program to do the calculations.

In procedural programming, here is what the code would look like to get the *'n*th' number in the Fibonacci sequence:

second = 1

for i in range(n-1):

fib = first + second

first = second

second = fib

print fib

This particular example uses the Python programming language, but the code looks similar in another procedural language.

The basic idea behind this code is that you would use a looping structure that iterates a series of steps. With every iteration, you get the next value in the sequence. After one iteration, the value of the variable *fib* is 1, after the second iteration the value is 2, etc. You repeat this *n*-1 times, where *n* represents the number in the sequence you are interested in.

Now let's look at the same task in a functional programming language. Here is what the code would look like:

start(n) -fib(0,1,n).fib(_,b,1) -b;

fib(a,b,n) - fib(b,a+b,n-1).

This particular example uses the Erlang language.

There are some key differences with the previous example. First, there is no series of small steps to calculate the number, but only a function that does the entire calculation. Notice how the function actually looks very similar to the mathematical description of the Fibonacci sequence.

Second, there is no clearly recognizable loop. The third line of code is a recursive function that keeps repeating itself. Every time the function performs a new calculation, the value of *n* is reduced. When this reaches the value of 1, the function stops and returns to the value of *b*, which is the desired number in the sequence.

So what is the 100th number in the sequence? Here is the answer:

354,224,848,179,261,915,075

Both programs produce the same result but use a different approach. In general, procedural programming is more widely used. Functional programming is popular in academia but is also used in other areas that rely heavily on mathematical functions.

There are a number of alternative approaches to the programming process. Two very different approaches are procedural programming and functional programming. Procedural programming uses a very detailed list of instructions to tell the computer what to do step by step. This approach uses iteration to repeat a series of steps as often as needed. Functional programming is an approach to problem solving that treats every computation as a mathematical function. This approach uses recursion for a function to repeat itself.

After watching this lesson, you should be able to differentiate between procedural programming and functional programming.

To unlock this lesson you must be a Study.com Member.

Create your account

Are you a student or a teacher?

Already a member? Log In

BackWhat teachers are saying about Study.com

Already registered? Login here for access

Did you know… We have over 160 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

You are viewing lesson
Lesson
4 in chapter 9 of the course:

Back To Course

Business 109: Intro to Computing10 chapters | 84 lessons | 9 flashcard sets

- 5 Basic Elements Of Programming 9:16
- What Is Programming? - Definition & Introduction for Beginning Programmers 3:47
- Object-Oriented Programming vs. Procedural Programming 7:17
- Functional Programming and Procedural Programming 6:58
- Pseudocode: Definition & Examples 5:52
- Boolean Logic, Operators & Expressions 6:56
- What is a Computer Algorithm? - Design, Examples & Optimization 7:49
- Debugging and Compiling Code 9:19
- Go to Programming Methodology

- Computer Science 335: Mobile Forensics
- Electricity, Physics & Engineering Lesson Plans
- Teaching Economics Lesson Plans
- U.S. Politics & Civics Lesson Plans
- US History - Civil War: Lesson Plans & Resources
- HESI Admission Assessment Exam: Factors & Multiples
- HESI Admission Assessment Exam: Probability, Ratios & Proportions
- HESI Admission Assessment Exam: 3D Shapes
- HESI Admission Assessment Exam: Punctuation
- HESI Admission Assessment Exam: Linear Equations, Inequalities & Functions
- CPCE Prep Product Comparison
- CCXP Prep Product Comparison
- CNE Prep Product Comparison
- IAAP CAP Prep Product Comparison
- TACHS Prep Product Comparison
- Top 50 Blended Learning High Schools
- EPPP Prep Product Comparison

- History of Sparta
- Realistic vs Optimistic Thinking
- How Language Reflects Culture & Affects Meaning
- Logical Thinking & Reasoning Questions: Lesson for Kids
- Exceptions to the Octet Rule in Chemistry
- Database Hacking: Attack Types & Defenses
- Pride and Prejudice Discussion Questions
- Quiz & Worksheet - Frontalis Muscle
- Quiz & Worksheet - Dolphin Mating & Reproduction
- Octopus Diet: Quiz & Worksheet for Kids
- Quiz & Worksheet - Fezziwig in A Christmas Carol
- Flashcards - Measurement & Experimental Design
- Flashcards - Stars & Celestial Bodies
- Bullying in Schools | Types & Effects of Bullying
- Reading Comprehension Strategies & Resources for All Teachers

- Life Span Developmental Psychology for Teachers: Professional Development
- English Literature for Teachers: Professional Development
- Algebra for Teachers: Professional Development
- Remedial Contemporary Math
- Education 102: Literacy Instruction in the Elementary School
- Intelligence Testing: Homeschool Curriculum
- Foreign Exchange & Balance of Payments: Homeschool Curriculum
- Quiz & Worksheet - Classifying Substances Based on Chemical Reactions
- Quiz & Worksheet - Kinds of Amphetamines
- Quiz & Worksheet - Elements of Adult Development
- Quiz & Worksheet - Paranoia & Relationships with Sensory Changes
- Quiz & Worksheet - Homozygous Traits

- How is Alcohol Made? - Types & Production Methods
- Annelids: Types & Structure
- Supply and Demand Activities for Kids
- Indiana Science Standards
- Passing Score for the TExES Core Subjects EC-6
- 5th Grade Florida Science Standards
- How to Improve Math Skills
- 3rd Grade Math Centers
- What Are the NGSS Performance Expectations?
- How to Pass Microbiology
- Homeschooling in Louisiana
- Nebraska State Standards for Social Studies

- Tech and Engineering - Videos
- Tech and Engineering - Quizzes
- Tech and Engineering - Questions & Answers

Browse by subject