1 / 15

CIS 103 - Computer Programming Logic

CIS 103 - Computer Programming Logic. Programming Concepts Overview prepared by Jack Wilson Cerritos College. Topics. 1.1 Programs 1.2 Modules 1.3 Algorithms 1.4 Statements 1.5 Syntax & Semantics 1.6 Logic Planning Tools 1.7 Control Structures 1.8 Memory Concepts 1.9 Data Types.

halil
Download Presentation

CIS 103 - Computer Programming Logic

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Topics 1.1 Programs 1.2 Modules1.3 Algorithms1.4 Statements1.5 Syntax & Semantics1.6 Logic Planning Tools 1.7 Control Structures 1.8 Memory Concepts 1.9 Data Types 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 module 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 ] 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: • get a number • multiply the number by itself • return this value 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 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?“. 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: • Sequence • Selection • Repetition 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 2 Example 1 Programming Concepts Overview Property of Jack Wilson, Cerritos College

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

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

More Related