Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.

Slides:



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

Lecture 1: Overview of Computers & Programming
Overview of Programming and Problem Solving ROBERT REAVES.
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Computer Science-I (CSIT121) Dr. Junaid Ahmed Zubairi SUNY at Fredonia Room 210, Fenton ,
This set of slides is provided by the author of the textbook1 Introductory Topics (Continued) l Computer Components l Basic Control Structures l Problem.
1 Chapter 1 Introduction to Object-Oriented Programming.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
This set of slides is provided by the author of the textbook1 Introductory Topics l Computer Programming l Programming Life-Cycle Phases l Creating an.
Chapter 1 Introduction to Object- Oriented Programming and Problem Solving.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Ceng 230 Programming with C
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems/Headington Slides by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
CHAPTER 1: AN OVERVIEW OF PROGRAMMING INSTRUCTOR: MOHAMMAD MOJADDAM How to Program in C++
CS 115 Chapter 1 Overview of Programming and Problem Solving.
CHAPTER 1 AN OVERVIEW OF COMPUTERS AND PROGRAMMING LANGUAGES.
Tools make jobs easier to do -A computer is a tool used by many professions A computer can do many different jobs because they are programmable - Machine.
1 Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
1 Author: Nell Dale Chip Weems Mark Headington Published By Higher Education Press Jones and Bartlett Publishers.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 1 An Overview of Computers and Programming Languages.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
CHAPTER 1 Overview of Programming and Problem Solving.
1 Overview of Programming and Problem Solving Chapter 1.
Overview of Programming and Problem Solving. Objectives In this chapter you will: Learn about different types of computers Explore the hardware and software.
Introduction to C++ Programming Language
Chapter 1: An Overview of Computers and Programming Languages
S2008Final_part1.ppt CS11 Introduction to Programming Final Exam Part 1 S A computer is a mechanical or electrical device which stores, retrieves,
Overview of Programming and Problem Solving Textbook Chapter 1 1.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems/Headington.
Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
Chapter 1 Overview of Programming and Problem Solving 1.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
Beginning Snapshots Chapter 0. C++ An Introduction to Computing, 3rd ed. 2 Objectives Give an overview of computer science Show its breadth Provide context.
1 Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
CSE:141 Introduction to Programming Faculty of Computer Science, IBA BS-I (Spring 2010) Lecture 2.
Chapter 1 Overview of Programming and Problem Solving CS185/09 - Introduction to Programming Caldwell College.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
1 Overview of Programming Principles of Computers.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Chapter 1 An Overview of Computers and Programming Languages.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Software Engineering Algorithms, Compilers, & Lifecycle.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Introduction to Programming By: Prof. Muhammad Abu Baker Siddique 2 nd Lecture 1.
1 Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
Cosc175 - lec11 Overview History Hardware Software Software Development Life Cycle Programming Languages Structured Programming Defining the Problem.
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1 Overview of Programming and Problem Solving
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
SOFTWARE DESIGN & DEVELOPMENT
Chapter 1 Overview of Programming and Problem Solving
What is Computer Programming?
Overview History Hardware Software Software Development Life Cycle
Introduction to Computer Programming
Presentation transcript:

Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving

What is Computer Science? The Computing Curriculum 1991 (ACM/IEEE) Algorithms and Data Structures Architecture Artificial Intelligence and Robotics Database and Information Retrieval Human-Computer Communication Numerical and Symbolic Computation Operating Systems Programming Languages Software Engineering Social and Professional Context

Machine Language Is not portable Runs only on specific type of computer Is made up of binary-coded instructions (strings of 0s and 1s) Is the language that can be directly used by the computer.

High Level Languages Are portable User writes program in language similar to natural language Compiler translates high-level language program into machine language Examples of high level languages FORTRAN, ALGOL, BASIC, COBOL, Pascal, C, Ada, Modula-2, C++

Early History of C Ken Thompson at AT&T’s Bell Labs begins to design UNIX operating system Writing UNIX using assembly language on DEC PDP-7 For more powerful PDP-11 wants to write UNIX in a high level language No appropriate high-level language exists

More C++ History Thompson designs new B language Dennis Ritchie at Bell Labs designs C and 90% of UNIX is then written in C Late 70’s -- OOP becomes popular Bjarne Stroustrup at Bell Labs adds features to C to form “C with Classes” Name C++ first used

Three Program Stages other code from libraries, etc. other code from libraries, etc. written in machine language written in machine language written in machine language written in machine language written in C++ written in C++ via compilervia linker SOURCEOBJECT EXECUTABLE myprog.cppmyprog.objmyprog.exe

Computer Components Arithmetic Logic Unit Memory Unit ( RAM & Registers ) Control Unit Input Device Output Device Auxiliary Storage Device Central Processing Unit ( CPU )

Memory Organization Two circuit states correspond to 0 and 1. Bit (short for binary digit) refers to a single 0 or 1. Bit patterns represent both the computer instructions and computer data. 1 byte = 8 bits 1 KB = 1024 bytes 1 MB = 1024 x 1024 = 1,048,576 bytes

Binary Numbers System Place Number System Two Digits; 1 and 0 1 st position is 2 to 0 power = 1 2 nd position is 2 to 1 power = 2 3 rd position is 2 to 2 power = 4 4 th position is 2 to 3 power = 8 5 th position is 2 to 4 power = 16

Binary Numbers System in binary is equal to 1 base in binary is equal to 63 base in binary is equal to 5 base in binary is equal to 16 base in binary is equal to 57 base in binary is equal to 7 base in binary is equal to 6 base 10

How Many Possible Digits? Binary (Base 2) Numbers use 2 digits: JUST 0 and 1 Decimal (Base 10) Numbers use 10 digits: 0 THROUGH 9

Basic Programming Structures A sequence is a series of statements to be executed one after another. Selection (branch) is a structure that executes different statements depending on certain conditions. Looping (repetition) is a structure to repeat statements while certain conditions are met. The subprogram is used to break the program into smaller units.

SEQUENCE Statement...

SELECTION (branch) IF Condition THEN Statement1 ELSE Statement2 Statement1 Statement Statement2 Condition... True False

LOOP (repetition) Statement Condition... False True WHILE Condition DO Statement1

SUBPROGRAM (function) SUBPROGRAM1... SUBPROGRAM1 a meaningful collection of SEQUENCE, SELECTION, LOOP, SUBPROGRAM

Programming Life Cycle 1 Problem-Solving Phase Analysis and Specification General Solution ( Algorithm Development ) 2 Implementation Phase Concrete Solution ( Program ) Test 3 Maintenance Phase Use Maintain

Sample Problem A programmer needs an algorithm to determine an employee’s weekly wages. How would the calculations be done by hand?

One Employee’s Wages During one week an employee works 52 hours at the hourly pay rate $24.75 How much is the employee’s wages? Assume a 40.0 hour normal work week. Assume an overtime pay rate factor of x $ = $ x 1.5 x $ = $ ___________ $

Problem-Solving Phase What information will be used? INPUT VALUE from outside the program CONSTANT VALUE assumed in program COMPUTED VALUE produced by program OUTPUT VALUE written to file or screen by program

Problem-Solving Phase INPUT CONSTANTSOUTPUT Hourly payRate Hours worked Normal work hours ( 40.0 ) Overtime pay rate factor (1.5) Hourly payRate Hours worked Wages COMPUTED VALUE Wages

If hours is over 40.0, then wages = (40.0 * payRate) + (hours ) * 1.5 *payRate otherwise, wages = hours * payRate Weekly Wages, in General RECALL EXAMPLE ( 40 x $ ) + ( 12 x 1.5 x $ ) = $

An Algorithm is... a step-by-step procedure for solving a problem in a finite amount of time.

Algorithm to Determine an Employee’s Weekly Wages 1. Get the employee’s hourly payRate 2. Get the hours worked this week 3. Calculate this week’s regular wages 4. Calculate this week’s overtime wages (if any) 5. Add the regular wages to overtime wages (if any) to determine total wages for the week

Implementation Phase: Program Translate your algorithm into a programming language. With C++, you use Documentation -- written explanations Compiler -- translates your program into machine code Main Program -- may call subalgorithms

Implementation Phase: Test TEST the program using sample input data for which correct results are already known, or can be manually checked. Use a variety of sample data to test many situations. If you find errors, analyze the program and algorithm to determine their source, and make corrections.

Maintenance Phase USE and MODIFY the program to meet changing requirements or correct errors that show up in using it.