Presentation on theme: "CS102 Introduction to Computer Programming"— Presentation transcript:
1 CS102 Introduction to Computer Programming Week 1Introduction and Chapter 1
2 Chapter 1 Intro to Programming and Program Design Why Program?Computer Systems : Hardware and SoftwarePrograms and Programming LanguagesWhat is a Program Made of?Input, Processing and OutputThe Programming ProcessProcedural and Object-Oriented Programming
3 Why Program? Computers perform a wide variety of tasks. Computer programmers provide the software for computers.Software transforms a general purpose computer into a specialized tool.Concept - Computers can do many different jobs because they are programmable.
4 What is Programming?Computers are designed to execute a set of instructions.Programming is the act of creating a set of instructions for a computer to execute.A set of instructions that performs a specific task is called an algorithm.Concept - A program is a set of instructions that a computer follows in order to perform a task.
5 Concept – Make a general purpose machine perform a specific task. What a programmer doesA programmer creates the following things:The logical flow of the instructionsThe mathematical proceduresThe appearance of the screensThe way information is presented to the userThe program's user friendlinessManuals and other forms of written documentationConcept – Make a general purpose machine perform a specific task.
6 Computer Systems : Hardware and Software Central Processing UnitMain MemorySecondary StorageInput DevicesOutput DevicesSoftware :loaded from a secondary storage device into main memoryComputerCPUInputDeviceOutputDeviceMainMemorySecondaryStorage
7 Central Processing Unit The CPU consists of two partsControl UnitPerforms three functionsFetchDecodeExecuteArithmetic & Logic UnitPerforms math operationsAddShiftAndOrConcept - The CPU is the heart of the computer.
8 Main Memory Referred to as: Holds the program during execution Random Access Memory (RAM)Static or dynamicVolatileRead Only Memory (ROM)Non-volatileHolds the program during executionDivided into equal sections called cellsEach cell has a unique address
9 Secondary StorageUsed to store programs and data for long periods of time:Hard DrivesFloppyZip DrivesCategorized by speed and capacityDigital TapeCD ROMSFlash Memory Cards
10 Input Devices Provide data to the CPU to be processed: KeyboardsTouch sensitive screensSecondary storage devicesProvide information in a variety of formats:Some conform to standards.Some are application unique.MicrophonesCamerasScanners
11 Output Devices Displays or stores data for the user: MonitorsPrintersSpeakersConsider the complexity of multimedia output.Disk DrivesModemsServers
12 Concept – Software connects the user to the machine The instructions that tell the computer and all of its devices what to do.When and what data to getWhat and how to manipulate the dataWhen and how to provide it to the userConcept – Software connects the user to the machine
13 Programming Languages Computers use machine language consisting of numbers only.Humans have difficulty communicating purely in numbers.A programming language provides a way for humans to communicate with a computerConcept - A program language is a special language used to write computer instructions.
14 Some Popular Programming Languages BASIC Beginners All-purpose Symbolic Instruction Code. A general programming language originally designed to be simple enough for beginners to learn.FORTRAN Formula Translator. A language designed for programming complex mathematical algorithms.COBOL Common Business-Oriented Language. A language designed for business applications.Pascal A structured, general purpose language designed primarily for teaching programming.C A structured, general purpose language developed at Bell Labs. C offers both high-level and low-level features.C++ Based on the C language, C++ offers object-oriented features not found in C. Also invented at Bell Laboratories.Java An object-oriented language invented at Sun Microsystems. Java may be used to develop programs that run over the Internet, in a web browser.
15 The Importance of C++ C++ is based on the C programming language. C++ is a midlevel language containing both high level and low level instructions.C++ is portable meaning that a C++ program can run a wide range of computers.Concept - The popularity of C++ makes it an important language to learn.
16 Code Source Code Modified Source code Object Code Executable Code Text written by the programmer.Modified Source codeExpanded text produced by the Pre-processor.Object CodeMachine level code generated by the compiler.Executable CodeMachine level code generated by the linker.Source CodePre-processorModified Source CodeCompilerObject CodeLinkerExecutable Code
17 What is a Program Made of? Language DescriptionElementKey Words Words that have a special meaning. Key words may only be used for their intended purpose.Programmer Words or names defined by the programmer. They areDefined symbolic names that refer to variables or programmingSymbols routines.Operators Operators perform operations on one or more operands. An operand is usually a piece of data, like a number.Punctuation Punctuation characters mark the beginning or ending of a statement, or separate items in a list.Syntax Rules followed when constructing a program. Syntax dictates how key words and operators may be used, and where punctuation symbols must appear.Concept - There are certain elements common to all computer programming languages.
18 Concept - Programs are made of a complete statements. Lines and StatementsA line is one single line of program textA statement is:A complete instruction that causes the computer to perform some actionMay consist of more than one lineA C++ statement must end in a semicolon (;)Concept - Programs are made of a complete statements.
19 Concept - A program stores information in variables. Symbolic names that represent locations in the computer’s Random Access MUsed to reference information that may change throughout the execution of a programThe name of a variable should reflect the purpose of the data it referencesConcept - A program stores information in variables.
20 Variable Declarations Variables are either numbers or charactersA variable declaration statement informs the compiler:the name that will be assigned to the variablehow it should be stored in memoryit's initial value (optional)A variable definition statement causes a variable to be created in memory.Concept - Variables must be defined before they are used.
21 Input, Process, and Output A program takes data as input, processes it and returns new data as output:Input usually comes from some external source but can be the output of another process.Output is usually sent to an external device but could be input to another process.A process determines the content of the output.Concept - The three primary activities of a program are input, processing, and output.
22 The Programming Process 1. Clearly define what the program is to do.2. Visualize the program running on the computer.3. Design a flow or Hierarchy chart.4. Check the chart for logical errors.5. Write a pseudocode version of the program.6. Check the pseudocode for errors.7. Write the actual program on paper.8. Desk check the program for syntax or logical errors.9. Enter the code and compile it.10 . Correct any errors found during compilation.11. Run the test data for input .12. Correct any logical errors found while running the program.Concept - There are a number of steps involved in successfully creating a program.
23 What is Software Engineering? UsersNeedsDeliverAnalyzeMaintainDebugSpecifyDesignCodeTestModifyDocumentConcept - Software engineering encompasses the whole process of crafting computer software.
24 Procedural and Object-Oriented Programming Procedural programming organizes code into functional subroutines that perform specific types of tasks.Object oriented programming addresses the relationships between program features.Concept - Procedural programming and object-oriented programming are two ways of thinking about software development and program design