CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
13-1 Programming… General Purpose The computer is a “general purpose” tool –General purpose means it can do more than one thing –How do we make.
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS
Algorithms and Program Development
Chapter 2- Visual Basic Schneider
Program Flow Charting How to tackle the beginning stage a program design.
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.
PRE-PROGRAMMING PHASE
The Computer Continuum4-1 Chapter 4: Computer Languages, Algorithms and Program Development How do computers know what we want them to do?
Fundamentals of C programming
ALGORITHMS AND FLOWCHARTS
Computer Languages, Algorithms and Program Development
The Computer Continuum4-1 Computer Languages,. The Computer Continuum4-2 Computer Languages n In this chapter: What makes up a language and how do we.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Software Life Cycle What Requirements Gathering, Problem definition
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
1 Program Planning and Design Important stages before actual program is written.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
FOUNDATION IN INFORMATION TECHNOLOGY (CS-T-101) TOPIC : INFORMATION SYSTEM – SOFTWARE.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
LESSON 1 Introduction to Programming Language. Computer  Comprised of various devices that are referred to as HARDWARE.  The computer programs that.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
 Problem Analysis  Coding  Debugging  Testing.
The Computer Continuum4-1 Chapter 4: Computer Languages, Algorithms and Program Development How do computers know what we want them to do?
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Chapter 1 Introduction 2nd Semester H
Programming what is C++
GC101 Introduction to computers and programs
Programming Languages
Unit 3: ALGORITHMS AND FLOWCHARTS
CSCI-235 Micro-Computer Applications
Computer Programming.
Chapter 2- Visual Basic Schneider
ALGORITHMS AND FLOWCHARTS
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
CS111 Computer Programming
Algorithms and Flowcharts
An Introduction to Visual Basic .NET and Program Design
Computer Programming.
ALGORITHMS AND FLOWCHARTS
Unit# 9: Computer Program Development
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
Chapter 2- Visual Basic Schneider
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Chapter 1 Introduction(1.1)
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
ICT Gaming Lesson 2.
Introduction to Programming
Chapter 1 Introduction to Programming
Programming Logic and Design Eighth Edition
Presentation transcript:

CHAPTER 2 GC101 Program’s algorithm 1

COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer binary circuitry.  Programming language: A series of specifically defined commands designed by human programmers to give directions to digital computers.  Commands are written as sets of instructions, called programs.  All programming language instructions must be expressed in binary code before the computer can perform them. 2

THE ROLE OF LANGUAGES IN COMMUNICATION  Three fundamental elements of language that contribute to the success or failure of the communication cycle:  Semantics  Syntax  Participants 3

THE ROLE OF LANGUAGES IN COMMUNICATION  Computer language:  Refers to the specific command you wish the computer to perform.  Input, Output, Print  Each command has a very specific meaning.  Computers associate one meaning with one computer command. n Semantics: Refers to meaning. 4

THE ROLE OF LANGUAGES IN COMMUNICATION  Computer language:  Refers to rules governing exact spelling and punctuation, plus:  Formatting, repetition, subdivision of tasks, identification of variables, definition of memory spaces.  Computers do not tolerate syntax errors. n Syntax: Refers to form, or structure. 5

THE ROLE OF LANGUAGES IN COMMUNICATION  Computer language:  People use programming languages.  Programs must be translated into binary code.  Computers respond by performing the task or not! n Participants: Human languages are used by people to communicate with each other. Programming languages are used by people to communicate with machines. 6

THE PROGRAMMING LANGUAGE  First Generation - Machine Language (code)  Machine language programs were made up of instructions written in binary code.  This is the “native” language of the computer. 7

THE PROGRAMMING LANGUAGE  Second Generation - Assembly Language  Assembly language programs are made up of instructions written in mnemonics.  Mnemonics: Uses convenient alphabetic abbreviations to represent operation codes, and abstract symbols to represent operands.  Each instruction had two parts: Operation code, Operand  Hardware dependent.  Because programs are not written in 1s and 0s, the computer must first translate the program before it can be executed. READnum1 READnum2 LOADnum1 ADDnum2 STOREsum PRINTsum STOP 8

THE PROGRAMMING LANGUAGE  Third Generation - People-Oriented Programs  Instructions in these languages are called statements.  High-level languages: Use statements that resemble English phrases combined with mathematical terms needed to express the problem or task being programmed.  Transportable: NOT-Hardware dependent.  Because programs are not written in 1s and 0s, the computer must first translate the program before it can be executed. 9

THE PROGRAMMING LANGUAGE  Fourth Generation - Non-Procedural Languages  Programming-like systems aimed at simplifying the programmers task of imparting instructions to a computer.  Many are associated with specific application packages.  Query Languages:  Report Writers:  Application Generators: 10

THE PROGRAMMING LANGUAGE  Fifth Generation - Natural Languages  Natural-Language: Languages that use ordinary conversation in one’s own language.  Research and experimentation toward this goal is being done.  Intelligent compilers are now being developed to translate natural language (spoken) programs into structured machine-coded instructions that can be executed by computers.  Effortless, error-free natural language programs are still some distance into the future. 11

ASSEMBLED, COMPILED, OR INTERPRETED LANGUAGES  All programs must be translated before their instructions can be executed.  Computer languages can be grouped according to which translation process is used to convert the instructions into binary code:  Assemblers  Interpreters  Compilers 12

ASSEMBLED, COMPILED, OR INTERPRETED LANGUAGES  Assembled languages:  Assembler: a program used to translate Assembly language programs.  Produces one line of binary code per original program statement.  The entire program is assembled before the program is sent to the computer for execution. 13

ASSEMBLED, COMPILED, OR INTERPRETED LANGUAGES  Interpreted Languages:  Interpreter: A program used to translate high-level programs.  Translates one line of the program into binary code at a time:  An instruction is fetched from the original source code.  The Interpreter checks the single instruction for errors. (If an error is found, translation and execution ceases. Otherwise…)  The instruction is translated into binary code.  The binary coded instruction is executed.  The fetch and execute process repeats for the entire program. 14

ASSEMBLED, COMPILED, OR INTERPRETED LANGUAGES  Compiled languages:  Compiler: a program used to translate high-level programs.  Translates the entire program into binary code before anything is sent to the CPU for execution.  The translation process for a compiled program:  First, the Compiler checks the entire program for syntax errors in the original source code.  Next, it translates all of the instructions into binary code.  Two versions of the same program exist: the original source code version, and the binary code version (object code).  Last, the CPU attempts execution only after the programmer requests that the program be executed. 15

4-16 BUILDING A PROGRAM  Whatever type of problem needs to be solved, a careful thought out plan of attack, called an algorithm, is needed before a computer solution can be determined. 1) Developing the algorithm. 2) Writing the program. 3) Documenting the program. 4) Testing and debugging the program.

4-17 BUILDING A PROGRAM  1) Developing the algorithm.  Algorithm: A detailed description of the exact methods used for solving a particular problem.  To develop the algorithm, the programmer needs to ask:  What data has to be fed into the computer?  What information do I want to get out of the computer?  Logic: Planning the processing of the program. It contains the instructions that cause the input data to be turned into the desired output data.

4-18 BUILDING A PROGRAM  A step-by-step program plan is created during the planning stage.  Major notations for planning detailed algorithms:  Flowchart: Series of visual symbols representing the logical flow of a program.  Pseudocode: A verbal shorthand method that closely resembles a programming language, but does not have to follow a rigid syntax structure.

PSEUDOCODE & ALGORITHM  Example 1: Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks.

PSEUDOCODE & ALGORITHM Pseudocode:  Input a set of 4 marks  Calculate their average by summing and dividing by 4  if average is below 50 Print “FAIL” else Print “PASS”

PSEUDOCODE & ALGORITHM Algorithm Step 1: Input M1,M2,M3,M4 Step 2: GRADE  (M1+M2+M3+M4)/4 Step 3: if (GRADE < 50) then Print “FAIL” else Print “PASS” endif

THE FLOWCHART  (Technical) A graphical representation of the sequence of operations in an information system or program.  Program flowcharts show the sequence of instructions in a single program or subroutine. Different symbols are used to draw each type of flowchart.

FLOWCHART SYMBOLS Basic

EXAMPLE PRINT “PASS” Step 1: Input M1,M2,M3,M4 Step 2: GRADE  (M1+M2+M3+M4)/4 Step 3: if (GRADE <50) then Print “FAIL” else Print “PASS” endif START Input M1,M2,M3,M4 GRADE  (M1+M2+M3+M4)/4 IS GRADE<5 0 PRINT “FAIL” STOP Y N

EXAMPLE 2 Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Pseudocode  Input the width (W) and Length (L) of a rectangle  Calculate the area (A) by multiplying L with W  Print A

EXAMPLE 2 Algorithm  Step 1: Input W,L  Step 2: A  L x W  Step 3: Print A START Input W, L A  L x W Print A STOP

4-27 BUILDING A PROGRAM 2) Writing the Program  If analysis and planning have been thoroughly done, translating the plan into a programming language should be a quick and easy task. 3) Documenting the Program  During both the algorithm development and program writing stages, explanations called documentation are added to the code.  Helps users as well as programmers understand the exact processes to be performed.

4-28 BUILDING A PROGRAM 4) Testing and Debugging the Program.  The program must be free of syntax errors.  The program must be free of logic errors.  The program must be reliable. (produces correct results)  The program must be robust. (able to detect execution errors)