Presentation is loading. Please wait.

Presentation is loading. Please wait.

Property of Jack Wilson, Cerritos College1 CIS 103 - Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.

Similar presentations


Presentation on theme: "Property of Jack Wilson, Cerritos College1 CIS 103 - Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College."— Presentation transcript:

1 Property of Jack Wilson, Cerritos College1 CIS 103 - Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College

2 Programming Concepts Overview Property of Jack Wilson, Cerritos College 2 Topics 1.1Programs 1.2Modules 1.3Algorithms 1.4Statements 1.5Syntax & Semantics 1.6Logic Planning Tools 1.7Control Structures 1.8Memory Concepts 1.9Data Types

3 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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

4 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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: 1.get a number 2.multiply the number by itself 3.return this value

6 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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: 1. Sequence 2. Selection 3. Repetition

9 Programming Concepts Overview Property of Jack Wilson, Cerritos College 9 1.6 Control Structures Sequence Structure A single statement or multiple statements executed sequentially, one after another. Example 1 Example 2

10 Programming Concepts Overview Property of Jack Wilson, Cerritos College 10 1.6 Control Structures 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 Example 2 – Two paths of execution truefalse true

11 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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". Example 1: Pre-test loop Example 2: Post-test loop true false true

12 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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 Programming Concepts Overview Property of Jack Wilson, Cerritos College 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 Programming Concepts Overview Property of Jack Wilson, Cerritos College 15 1.9 Data Types Numeric  integer numbers  real numbers Text  a single character value  a "string" of characters Boolean  True  False Currency Date/Time Object Programs work with data ( information stored in locations in memory ). There are many different categories of data. 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: LanguageNumericTextBooleanCurrency Javaint long float double char String booleannot supported C++int long float double char char[ ] string boolnot supported VisualBasicInteger Long Single Double Char String BooleanDecimal


Download ppt "Property of Jack Wilson, Cerritos College1 CIS 103 - Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College."

Similar presentations


Ads by Google