Lecture Notes 8/24/04 (part 2) - PowerPoint PPT Presentation

About This Presentation
Title:

Lecture Notes 8/24/04 (part 2)

Description:

Get number of students. Read the names of the students from the file. Put Out Information ... Either actual mathematical symbols or words can be used: ... – PowerPoint PPT presentation

Number of Views:20
Avg rating:3.0/5.0
Slides: 11
Provided by: Ali4152
Learn more at: https://www.cse.unr.edu
Category:

less

Transcript and Presenter's Notes

Title: Lecture Notes 8/24/04 (part 2)


1
Lecture Notes 8/24/04 (part 2)
2
Pseudocode (review)
  • Pseudocode standard which we will follow in this
    class
  • - Statements are written in simple English
  • - Each instruction is written on a separate
    line
  • - Each set of instructions is written from
    top to bottom, with only
  • one entry and one exit
  • - Groups of statements may be formed into
    modules, and that
  • group given a name.

3
How to Write Pseudocode
  • 6 basic computer operations
  • receive information
  • put out information
  • perform arithmetic
  • assign a value to a variable or memory location
  • compare two variables and select one of two
    alternative actions
  • repeat a group of actions

4
Receive Information
  • A computer generally gets information in one of
    the following ways
  • From a file
  • Pseudocode -gt Read
  • From a keyboard
  • Pseudocode -gt Get

5
Receive Information
  • Examples
  • Get file name
  • Read first line from the file
  • Get number of students
  • Read the names of the students from the file

6
Put Out Information
  • A computer generally outputs information in one
    of the three ways
  • Print on a printer
  • Print
  • Write to a file
  • Write
  • Display on a monitor
  • Display

7
Put Out Information
  • Examples
  • Print Hello everyone!
  • Write My first homework to hw_1.txt
  • Display average_age

8
Perform Arithmetic
  • Either actual mathematical symbols or words can
    be used
  • Multiply Length by Width to compute Area
  • Area Length Width

9
Perform Arithmetic
  • Symbols that will be used in this class
  • Addition
  • Subtraction -
  • Division /
  • Multiplication
  • Modulus
  • Parentheses ()
  • Also can use the words Compute and Calculate

10
Example
  • Write the pseudocode for calculating the average
    age of the students in our class.
  • Prompt the user for number of students
  • Get number of students
  • Prompt for all of the ages
  • Get the ages of all students
  • Add all ages together to obtain Total_Age
  • Divide Total_Age by the number of students
  • Display the result
Write a Comment
User Comments (0)
About PowerShow.com