CIS 103 - Computer Programming Logic - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

CIS 103 - Computer Programming Logic

Description:

Property of Jack Wilson, Cerritos College. CIS 103 - Computer Programming Logic. Programming Concepts . Overview. prepared by Jack Wilson. Cerritos College – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 16
Provided by: JackW168
Category:

less

Transcript and Presenter's Notes

Title: CIS 103 - Computer Programming Logic


1
CIS 103 - Computer Programming Logic
  • Programming Concepts
  • Overview
  • prepared by Jack Wilson
  • Cerritos College

2
Topics
  • 1.1 Programs
  • 1.2 Modules1.3 Algorithms1.4 Statements1.5 Synt
    ax Semantics1.6 Logic Planning Tools
    1.7 Control Structures 1.8 Memory Concepts
  • 1.9 Data Types

3
1.1 Programs
  • A program contains one or more modules.
  • Some languages require a module with a special
    name, such as "main" for a program to be
    created.
  • Programs are often also referred to as
    applications or more generally as software.

Program
module
module
4
1.2 Modules
  • A module is a collection of statements that
    performs a specific task within a program.
  • Module is a generic term. Programming languages
    uses different names for modules. Examples
    include
  • function C, C, VisualBasic
  • method Java
  • subprocedure VisualBasic

5
1.3 Algorithms
  • An algorithm is the name given to the logic that
    is developed and used to code the statements in a
    module.

Implementation of the algorithm in a module
(function) double square ( double number )
return number number
  • Algorithm to square a number
  • get a number
  • multiply the number by itself
  • return this value

6
1.4 Statements
  • A statement is the name given to a high level
    language instruction.
  • Programs are written using a variety of different
    types of statements. Examples include
  • Input
  • Output
  • Declaration
  • Assignment
  • Processing
  • Compiler / Pre-Processor Directives

7
1.5 Syntax Semantics
  • Syntax refers to the rules of a language that
    must be followed to construct a valid statement.
    Statements are constructed using the following
    components
  • reserved words ( aka keywords )
  • identifiers
  • operators
  • literals
  • punctuation symbols
  • Semantics refers to the meaning of a statement.
    It addresses the question "What does the
    statement do?.

8
1.6 Control Structures
  • A control Structure determines the flow of
    execution for statements executing in a module.
  • There are 3 control structures that are used in
    all programming languages
  • Sequence
  • Selection
  • Repetition

9
1.6 Control Structures
Sequence Structure A single statement
or multiple statements executed
sequentially, one after another.
Example 2
Example 1
10
1.6 Control Structures
true
false
Selection Structure Asks a question and based on
the answer ( true or false ) one of possibly 2
paths of execution is taken.
Example 1 One path of execution
true
false
Example 2 Two paths of execution
11
1.6 Control Structures
Repetition Structure Asks a question and based
on the answer ( true or false ) executes a
statement. Continues to execute the statement
as long as the question evaluates to yes. A
repetition structure is usually called a "loop".
true
false
Example 1 Pre-test loop
true
false
Example 2 Post-test loop
12
1.7 Logic Planning Tools
  • Pseudocode
  • Flowchart
  • IPO ( Input - Process Output ) Chart
  • Structure Chart
  • Decision Tree/Table
  • Printer Spacing Chart
  • Screen Layout Chart
  • Record Layout Form text file
  • Table Definition database file

13
1.8 Memory Concepts
  • Memory is measured in bytes ( MB / GB / TB )
  • A byte is 8 bits ( binary digits )
  • Every byte is assigned a unique address in
    memory
  • Data types use one or more bytes to store
    information
  • There are different formats for storing different
    types of data. Characters are stored quite
    differently than are real numbers or dates.

14
1.8 Memory Concepts
  • To avoid having to reference a specific location
    in memory to access a piece of data, variable
    names are used instead of addresses. To use a
    variable in a program, you must declare the
    variable by giving it a name and a data
    type.Examples
  • int count boolean finished Dim name As
    String
  • When a program is executed, a symbol table (
    think of it as a data dictionary in memory ) is
    created that maps the name of a variable to the
    location in memory where the data is being
    stored.

15
1.9 Data Types
Programs work with data ( information stored in
locations in memory ).There are many different
categories of data.
  • Numeric
  • integer numbers
  • real numbers
  • Text
  • a single character value
  • a "string" of characters
  • Boolean
  • True
  • False
  • Currency
  • Date/Time
  • Object

Every language has a specific keywords which are
used to specify a data type. Not all data types
are supported in all languages. Here are some
examples
Language Numeric Text Boolean Currency
Java int long float double char String boolean not supported
C int long float double char char string bool not supported
VisualBasic Integer Long Single Double Char String Boolean Decimal
Write a Comment
User Comments (0)
About PowerShow.com