Introduction to Programming

Slides:



Advertisements
Similar presentations
How Are Algorithms Developed?
Advertisements

Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 2 - Problem Solving
زبانهای برنامه سازی برنامه سازی پیشرفته ارائه دهنده دکتر سيد امين حسيني E.mail: Home page:
 Introduction to Programming History of programming.
Chapter 2- Visual Basic Schneider
CIS105 Chapter 1 Theory Review. Page 2 Hardware and Software are the two major components o any computer system Hardware is the set of physical devices.
The Program Development Cycle and Program Design Tools
Program Flow Charting How to tackle the beginning stage a program design.
Program Development and Programming Languages
Chapter 2: Developing a Program Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved.
An Introduction to Programming with C++ Fifth Edition Chapter 1 An Introduction to Programming.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Chapter 3 Planning Your Solution
The Program Design Phases
An Overview of Computers and Programming
PRE-PROGRAMMING PHASE
Intro to Programming CST JavaScript. Objectives Define software Identify the different types of software Differentiate the different types of programming.
Copyright © 2001 by Wiley. All rights reserved. Chapter 1: Introduction to Programming and Visual Basic Computer Operations What is Programming? OOED Programming.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
Learning Objectives Data and Information Six Basic Operations Computer Operations Programs and Programming What is Programming? Types of Languages Levels.
CPS 120: Introduction to Computer Science
CC111 Lec#5: Program Development 1 Program Development and Programming Languages Lecture 4 Reference :Understanding Computers Chapter 13.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
An Introduction to Programming with C++ Sixth Edition
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Programming Lifecycle
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
Introduction to Computers (L02) * Hardware * Software * Programming Languages * Three Phase of Program Development * Development and Design Steps * Algorithms.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
CPS120 Introduction to Computer Programming The Programming Process.
ENGR-25_Programming-1.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Registered Electrical.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
BACS 287 Programming Logic 1. BACS 287 Programming Basics There are 3 general approaches to writing programs – Unstructured – Structured – Object-oriented.
CPS120: Introduction to Computer Science Decision Making in Programs.
Control Structures CPS120: Introduction to Computer Science Lecture 5.
CHAPTER 1 INTRODUCTION 1 st semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Chapter One An Introduction to Programming and Visual Basic.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Introduction to Computing Dr. Nadeem A Khan. Lecture 2.
Prof. Ken Regis Institute for Computer Engineering Florida State University Oktober 2002Prof. Ken Regis - FIT 1-11.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
FLOWCHARTING AND ALGORITHMS
Alexandria University Faculty of Science Computer Science Department Introduction to Programming C++
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Introduction to Computer Programming using Fortran 77.
CPS120: Introduction to Computer Science Session 5.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Computer Programming.
Chapter 2- Visual Basic Schneider
Introduction to Computer Programming
Unit# 9: Computer Program Development
CPS120: Introduction to Computer Science
Chapter 2- Visual Basic Schneider
Introduction to Algorithms and Programming
Chapter 2- Visual Basic Schneider
How Are Algorithms Developed?
CPS120: Introduction to Computer Science
Programming Logic and Design Eighth Edition
Presentation transcript:

Introduction to Programming Prof. George Zolla Prof. Gary Porter (IS 2020) .

Programs A program is a set of step-by-step instructions that directs the computer to do the tasks you want it to do and produce the results you want.

Programming Languages A programming language is a set of rules that provides a way of telling a computer what operations to perform.

What Can a Program Do? A program can only instruct a computer to: Read Input Sequence Calculate Store data Compare and branch Iterate or Loop Write Output

Sequence Control Structures Sequence control structures direct the order of program instructions. The fact that one instruction follows another—in sequence—establishes the control and order of operations.

Calculate Add 1 to Counter A program can instruct a computer to perform mathematical operations. Add 1 to Counter

Store A program will often instruct a computer to store intermediate results. Place 1 in Counter

Compare and Branch A program can instruct a computer to compare two items and do something based on a match or mismatch which, in turn, redirect the sequence of programming instructions. There are two forms: IF-THEN IF-THEN-ELSE

IF-THEN false true Entry Exit True statement a Test condition p

IF-THEN-ELSE Entry Exit Test condition p “true” statement a false true Entry Exit Test condition p “true” statement a “false” statement a

Iterate A program loop is a form of iteration. A computer can be instructed to repeat instructions under certain conditions. No

Iteration Control Structures Iteration control structures are looping mechanisms. Loops repeat an activity until stopped. The location of the stopping mechanism determines how the loop will work: Leading decisions Trailing decisions

Leading Decisions If the stop is at the beginning of the iteration, then the control is called a leading decision. The command DO WHILE performs the iteration and places the stop at the beginning.

DO WHILE Loop No Yes Entry Exit Test condition p Loop statement a

Trailing Decisions If the stop is at the end of the iteration, the control mechanism is called a trailing decision. The command DO UNTIL performs the iteration and puts the stop at the end of the loop.

DO UNTIL Loop No Yes Entry Test condition p Exit Loop statement a

Programs are Solutions to Problems Programmers arrive at these solutions by using one or more of these devices: Logic flowcharts Structure charts Pseudocode Structured Programming

Logic Flowcharts These represent the flow of logic in a program and help programmers “see” program design.

Common Flowchart Symbols Terminator. Shows the starting and ending points of the program. A terminator has flowlines in only one direction, either in (a stop node) or out (a start node). Data Input or Output. Allows the user to inputdata and results to be displayed. Processing. Indicates an operation performed by the computer, such as a variable assignment or mathematical operation. Decision. The diamond indicates a decision structure. A diamond always has two flowlines out. One flowlineout is labeled the “yes” branch and the other is labeled the “no” branch. Predefined Process. One statement denotes a group of previously defined statements. For instance, “Calculate m!” indicates that the program executes the necessary commands to compute m factorial. Connector. Connectors avoid crossing flowlines, making the flowchart easier to read. Connectors indicate where flowlines are connected. Connectors come in pairs, one with a flowline in and the other with a flowline out. Off-page connector. Even fairly small programs can have flowcharts that extend several pages. The off-page connector indicates the continuation of the flowchart on another page. Just like connectors, off-page connectors come in pairs. Flowline. Flowlines connect the flowchart symbols and show the sequence of operations during the program execution. Common Flowchart Symbols

Flowchart for a Cash Register Program Start sum=0 Input price sum=sum+price More items? tax=sum x 0.0725 total=sum+tax Output sum, tax, and total Stop No Yes

Structure Charts Structure charts illustrate the structure of a program by showing independent hierarchical steps. Major divisions are subdivided into smaller pieces of information.

Psuedocode This device is not visual but is considered a “first draft” of the actual program. Pseudocode is written in the programmer’s native language and concentrates on the logic in a program—not the syntax of a programming language.

Pseudocode for a Cash Register Program sum=0 While More items do Input price sum=sum+price End While tax=sum x 0.0725 total=sum+tax Output sum, tax, total

Structured Programming Structured program languages lend themselves to flowcharts, structure charts, and pseudocode. Structured programming languages work best where the instructions have been broken up into small, manageable parts.

The Program Development Cycle Analyze the problem Design the solution algorithm Design the user interface Write the code Test and debug the program Complete the documentation

Levels of Programming Languages Machine language Assembly Language High Level Languages Fourth Generation Languages (4GL)

Machine Languages different for each computer processor 0100 001101 100000 001101 110001 00101 10001 10000 01110 111001 . . .

Assembly Languages main proc pay mov ax, dseg mov ax, 0b00h add ax, dx different for each computer processor main proc pay mov ax, dseg mov ax, 0b00h add ax, dx mov a1, b1 mul b1, ax mov b1, 04h

High-Level Languages Higher Level Languages 4GLs Use traditional programming logic where the programming instructions tell the computer what to do and how to perform the required operations. 4GLs Use high-level English-like instructions to specify what to do, not how to do it .

Interpreter vs Compiler Translates instructions to machine code line-by-line. Compiler Translates the entire program to machine code before running it.

Types of Programming Languages Machine language Procedure-oriented languages Object-oriented languages Event-driven languages

Procedure-Oriented Languages FORTRAN COBOL Pascal C Ada

OOED Languages Object-oriented languages Event-driven languages Smalltalk C++ Ada 95 Event-driven languages Visual Basic most Visual languages

Programmer’s Lingo Program - detailed set of instructions for a computer Programming Language - tool used to create a program; defined by semantics and syntax Semantics - the meaning of words in a language Syntax - rules for combining symbols of a language

Programmer’s Lingo Source Code (code) - program you write using a programming language Interpreter - translates and executes source code statement by statement

Programmer’s Lingo Interpreter Process

Programmer’s Lingo Compiler Process