An Overview of Computers and Logic

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Fundamental of Programming(101) Why study Programming Language Concepts? Increased capacity to express programming concepts Improved background for choosing.
Starting Out with C++, 3 rd Edition 1 Chapter 1. Introduction to Computers and Programming.
COSC 120 Computer Programming
Chapter 1 An Overview of Computers and Logic
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.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
An Overview of Programming Logic and Design
Modules, Hierarchy Charts, and Documentation
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 1 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.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
Programming Logic and Design Fourth Edition, Introductory
An Overview of Computers and Programming
Computers & Logic An Overview. Hardware Hardware is the equipment, or the devices, associated with a computer. For a computer to be useful, however, it.
Introduction to Computers and Programming
CS102 Introduction to Computer Programming
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Programming Logic and Design Fifth Edition, Comprehensive
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
An Overview of Computers and Logic
Topics Introduction Hardware and Software How Computers Store Data
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
CIS Computer Programming Logic
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Design the program Create a detailed description of program –Use charts or ordinary language (pseudocode) Identify algorithms needed –Algorithm: a step-by-step.
Introduction to Computer Systems and the Java Programming Language.
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
Logic and Systems A beginner’s guide.
P ROGRAMMING L OGIC AND D ESIGN S IXTH E DITION Chapter 1 An Overview of Computers and Programming.
An Object-Oriented Approach to Programming Logic and Design Chapter 1 An Overview of Computers and Logic.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
What is Programming? A program is a list of instructions that is executed by a computer to accomplish a particular task. Creating those instructions is.
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 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.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Programming Logic and Design Seventh Edition
P ROGRAMMING L OGIC GWDA123 Sharon Kaitner, M.Ed. Winter 2015: Week 1.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Introduction to Computer Programming using Fortran 77.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
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.
Chapter 1: Introduction to Computers and Programming
Chapter 1 Introduction 2nd Semester H
DDC 1023 – Programming Technique
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
C++ Programming: From Problem Analysis to Program Design
Chapter 1: Introduction to Computers and Programming
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Chapter 4: Writing and Designing a Complete Program
Programming Logic and Design Eighth Edition
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

An Overview of Computers and Logic 1 An Overview of Computers and Logic Programming Logic and Design, Second Edition, Comprehensive Chapter 1

Objectives After studying Chapter 1, you should be able to: Understand computer components and operations Describe the steps involved in the programming process Describe the data hierarchy Understand how to use flowchart symbols and pseudocode statements Chapter 1

Objectives After studying Chapter 1, you should be able to: Use and name variables Use a sentinel, or dummy value, to end a program Use a connector symbol Assign values to variables Recognize the proper format of assignment statements Describe data types Chapter 1

Understanding Computer Components and Operations The two major components of any computer system are its hardware and its software Hardware is the equipment, or the devices, associated with a computer The instructions that tell the computer what to do are called software, or programs, and are written by programmers Hardware devices that perform input include keyboards and mice Chapter 1

Understanding Computer Components and Operations Together, computer hardware and software accomplish four major operations: Input Processing Output Storage Through these devices, data, or facts, enter the computer system Chapter 1

Understanding Computer Components and Operations Processing data items may involve organizing them, checking them for accuracy, or performing mathematical operations on them The piece of hardware that performs these sorts of tasks is the Central Processing Unit, or CPU You write computer instructions in a computer programming language such as Visual Basic, Pascal, COBOL, RPG, C#, C++, Java, or Fortran Chapter 1

Understanding Computer Components and Operations No matter which programming language a computer programmer uses, the language has rules governing its word usage and punctuation These rules are called the language’s syntax Every computer operates on circuitry that consists of millions of on-off switches Each programming language uses a piece of software to translate the specific programming language into the computer’s on-off circuitry language, or machine language Chapter 1

Understanding Computer Components and Operations The language translation software is called a compiler or interpreter, and it tells you if you have used a programming language incorrectly Syntax errors are relatively easy to locate and correct For each program to work properly, you must give the instructions to the computer in a specific sequence, you must not leave any instructions out, and you must not add extraneous instructions Chapter 1

Understanding Computer Components and Operations By doing this, you are developing the logic of the computer program Once instructions have been inputted into the computer and translated into machine language, a program can be run or executed The instructions to Get inputNumber is an example of an input operation Besides input, processing, and output, the fourth operation in any computer system is storage Chapter 1

Understanding Computer Components and Operations Storage comes in two broad categories All computers have internal storage, probably referred to more often as memory, main memory, or primary memory This storage is inside the machine and is the type of storage most often discussed in this book Computers also have external storage, which is permanent storage outside the main memory of the machine on a device such as a floppy disk, hard disk, or magnetic tape Chapter 1

Understanding Computer Components and Operations To use computer programs, you must first load them into memory A computer system needs both internal memory and external storage Internal memory is needed to run the programs, but internal memory is volatile—that is, its contents are lost every time the computer loses power Therefore, if you are going to use a program more than once, you must store it, or save it, on some nonvolatile medium Chapter 1

Understanding the Programming Process A programmer’s job involves writing instructions, and can be broken down into six programming steps: Understand the problem Plan the logic Code the program Translate the program into machine language Test the program Put the program into production Chapter 1

Understand the Problem Professional computer programmers write programs to satisfy the needs of others Because programmers are providing a service to these users, programmers must first understand what it is the users want Chapter 1

Plan the Logic The heart of the programming process lies in planning the program’s logic Phase: the programmer plans steps to the program : ** what steps to include ** how to order them Chapter 1

Code the Program The Acutual instruction writing, or coding of the program Chapter 1

Translate the Program into Machine Language a translator program (a compiler or interpreter) that changes the English-like high-level language in which the programmer writes into the low-level machine language that the computer understands Chapter 1

Test the Program A program that is free of syntax errors is not necessarily free of logical errors Once a program is free from syntax errors, the programmer can test , execute it with some test data to see whether or not the results are logically correct Programs should be tested with many sets of data Selecting test data is somewhat of an art in itself, and it should be done carefully Chapter 1

Put the Program into Production Once the program is tested adequately, it is ready for the organization to use Chapter 1

Understanding the Data Hierarchy Data stored for use on computer systems : data hierarchy, where the smallest usable unit of data is the character Characters are letters, numbers, and special symbols such as “A”, “7”, and “$” (1 byte) Characters are made up of smaller elements called bits ( 8 bits = 1 byte) A field is a single data item such as lastName, streetAddress, or annualSalary Chapter 1

Understanding the Data Hierarchy Records are groups of fields that are logically related Files are groups of records that are logically related Chapter 1

Understanding the Data Hierarchy A file contains many records Chapter 1

A File of Employee Records Chapter 1

Using Flowchart Symbols and Pseudocode Statements When programmers plan the logic for a solution to a programming problem, they often use one of two tools, flowcharts or pseudocode Flowchart : pictorial representation of the logical steps it takes to solve a problem Pseudocode: English-like representation of the solution Chapter 1

Using Flowchart Symbols and Pseudocode Statements Using pseudocode is more similar to writing the final statements in the programming language When you draw a flowchart, you use a parallelogram to represent an input operation You write an input statement, in English, inside the parallelogram Arithmetic operation statements are examples of processing To represent an output statement, you use the same symbol as you do for input statements Chapter 1

Using Flowchart Symbols and Pseudocode Statements Chapter 1

Using Flowchart Symbols and Pseudocode Statements To show the correct sequence of these statements, you use arrows, or flowlines, to connect the steps Chapter 1

Using Flowchart Symbols and Pseudocode Statements To be complete, a flowchart should include two more elements: a terminal or start/stop symbol at each end Chapter 1

Flowchart of Infinite Number-Doubling Program Chapter 1

Using and Naming Variables Programmers commonly refer to the locations in memory called inputNumber and calculateAnswer as variables Variables are memory locations, whose contents can vary or differ over time Every computer programming language has its own set of rules for naming variables Most languages allow both letters and digits within variable names Chapter 1

Using and Naming Variables Different languages put different limits on the length of variable names NOTE : When designing the logic of a computer program, you should not concern yourself with the specific syntax of any particular computer language Most programmers who use the more modern languages employ the format in which multiple-word variable names are run together, and each new word within the variable name begins with an uppercase letter Chapter 1

Using and Naming Variables This format is called camel casing, because such variable names, like hourlyWage, have a “hump” in the middle The logic works with any language The variable names used throughout this book follow only two rules: Variable names must be one word Variable names should have some appropriate meaning Chapter 1

Ending a Program by Using Sentinel Values A superior way to end the program is to set a predetermined value for inputNumber that means “Stop the program!” The program could then test any incoming value for inputNumber and, if it is a zero, stop the program Testing a value is also called making a decision You represent a decision in a flowchart by drawing a decision symbol or a diamond Chapter 1

Ending a Program by Using Sentinel Values The diamond usually contains a question, the answer to which is either yes or no All good computer questions have two mutually exclusive answers like yes and no or true and false One drawback to using zero to stop a program is that it won’t work if the user does need to find the double of zero Chapter 1

Flowchart for Number-Doubling Program with Sentinel Value of Zero Chapter 1

Ending a Program by Using Sentinel Values A preselected value that stops the execution of a program is often called a dummy value because it does not represent real data, but just a signal to stop Sometimes such a value is called a sentinel value because it represents an entry or exit point like a sentinel that guards a fortress Many programming languages use the term eof (for “end of file”) to talk about this marker Chapter 1

Flowchart Using EOF Chapter 1

Using the Connector By using just the input, processing, output, decision, and terminal symbols, you can represent the logic for many diverse applications the connector A connector will be used when limited page size forces you to continue the flowchart on the following page Chapter 1

Flowchart Using the Connector Chapter 1

Assigning Values to Variables When you create a flowchart or pseudocode for a program that doubles numbers, you can include the statement compute calculatedAnswer as inputNumber times 2 Most programming languages allow a shorthand expression for these assignment statements such as compute calculatedAnswer as inputNumber times 2 Chapter 1

Understanding Data Types Computers deal with two basic types of data—character and numeric When you use a specific number value, like 43, within a program, you write it using the digits and no quotation marks A specific numeric value is often called a numeric constant, because it does not change When you use a specific character value, or string of characters, like “Chris,” you enclose the string or character constant within quotation marks Chapter 1

Understanding Data Types Similarly, most computer languages allow at least two distinct types of variables One type of variable can hold a number and is often called a numeric variable Most programming languages have a separate type of variable that can hold letters of the alphabet and other special characters such as punctuation marks Depending on the language, these variables are called character, text, or string variables Chapter 1

Understanding Data Types Some languages have different rules for naming the variables, but with others you must include a simple statement (called a declaration) telling the computer which type of data to expect Languages like Pascal, C++, C#, and Java distinguish between integer or whole number variables, and floating-point or fractional numeric variables that contain a decimal point Chapter 1

Summary Together, computer hardware (equipment) and software (instructions) accomplish four major operations: input, processing, output, and storage You write computer instructions in a computer programming language that requires specific syntax A programmer’s job involves understanding the problem, planning the logic, coding the program, translating the program into machine language, testing the program, and putting the program into production Chapter 1

Summary When data are stored for use on computer systems, they are stored in a data hierarchy of character, field, record, and file When programmers plan the logic for a solution to a programming problem, they often use flowcharts or pseudocode Variables are named memory locations, the contents of which can vary Testing a value involves making a decision You represent a decision in a flowchart by drawing a diamond-shaped decision symbol which contains a question Chapter 1

Summary A circular connector symbol is used to continue a flowchart that does not fit on a single page Most programming languages allow the equal sign to assign values to variables Programmers must distinguish between numeric and character variables because computers handle the two types of data differently A variable declaration tells the computer which type of data to expect Chapter 1