< Return to Video

Flowchart for the Factorial Program

  • 0:01 - 0:03
    One thing you'll hear or see referred to a lot
  • 0:03 - 0:05
    is something called a flowchart
  • 0:05 - 0:07
    either in computer science, so really when people
  • 0:07 - 0:10
    talk about any type of algorithm or process.
  • 0:10 - 0:11
    So what I thought I would do
  • 0:11 - 0:13
    is for every program I write, is do a simple flowchart
  • 0:13 - 0:14
    maybe I won't do it for every one,
  • 0:14 - 0:14
    but I'll start with one of the basic ones,
  • 0:14 - 0:19
    just so we understand that a flowchart isn't anything fancy.
  • 0:19 - 0:23
    So in this factorial program that we had been looking at in the past couple videos
  • 0:23 - 0:27
    Any flowchart you're just going to be at a starting point
  • 0:27 - 0:32
    I guess, depicted with a circle or oval of some kind.
  • 0:32 - 0:37
    And so we start at this line above this assignment
  • 0:37 - 0:40
    of the number where we actually ask for input from the user.
  • 0:40 - 0:45
    And then after that, we ask for input from
  • 0:45 - 0:46
    the user. This line right here.
  • 0:46 - 0:49
    We are asking for input from the user.
  • 0:49 - 0:51
    So this right over here
  • 0:51 - 0:55
    And we will depict that by a parallelogram.
  • 0:55 - 0:57
    And that is input from the user.
  • 0:57 - 0:58
    And then we'll just say number
  • 0:58 - 1:03
    equals user input.
  • 1:03 - 1:06
    And you can be a little bit loosey-goosey with the terminology
  • 1:06 - 1:09
    here, you're really just trying to tell us what you're doing in this step.
  • 1:09 - 1:12
    The parallellogram tells us that we are somehow interfacing with the user.
  • 1:12 - 1:17
    We're either taking something from the user or we're outputting something to the user.
  • 1:17 - 1:19
    So here, we're saying user input is equal to number.
  • 1:19 - 1:22
    We're assigning number to user input.
  • 1:22 - 1:26
    Then, the next thing we do is just a straight up operation.
  • 1:26 - 1:29
    We just set product to be equal to 1
  • 1:29 - 1:33
    And there we just do that in a rectangle.
  • 1:33 - 1:36
    Product equals 1.
  • 1:36 - 1:41
    Product is equal to one.
  • 1:41 - 1:43
    And then, something interesting is going to happen.
  • 1:43 - 1:47
    We enter into our for loop.
  • 1:47 - 1:49
    And we start with, and what I'm going to do here
  • 1:49 - 1:52
    is I'm going to write it a little bit different than we wrote it over here.
Title:
Flowchart for the Factorial Program
Description:

Flowchart for the factorial program.

more » « less
Video Language:
English
Duration:
05:36

English subtitles

Revisions Compare revisions