CS 115 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.
ICS103 P ROGRAMMING IN C L ECTURE 1: O VERVIEW OF C OMPUTERS & P ROGRAMMING.
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.
CS 201 Overview of Computers & Programming Debzani Deb.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
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
Introduction to C++ Programming CS 117 Section 2 and KNET Sections Spring 2001 MWF 1:40-2:30.
Chapter 1: An Overview of Computers and Programming Languages
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.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
Python Programming, 2/e1 Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs.
CS102 Introduction to Computer Programming
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.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
CS 161 INTRO TO PROGRAMMING I Dr. Blaise W. Liffick Fall
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers, Problem Solving, and Programming Problem.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex.
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.
CHAPTER 1 Overview of Programming and Problem Solving.
Python Programming: An Introduction to Computer Science
CISC105 General Computer Science Class 1 – 6/5/2006.
1 Overview of Programming and Problem Solving Chapter 1.
Introduction to C++ Programming Language
Chapter 1: An Overview of Computers and Programming Languages
Overview of Programming and Problem Solving Textbook Chapter 1 1.
Problem Solving using the Science of Computing MSE 2400 EaLiCaRA Spring 2015 Dr. Tom Way.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Lecture 2 : Computer System and Programming. Computer? a programmable machine that  Receives input  Stores and manipulates data  Provides output.
1 Chapter 1 Overview of Programming and Problem Solving Dale/Weems/Headington.
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.
1 Chapter 1 Overview of Programming and Problem Solving Slides based on work by Sylvia Sorkin, Community College of Baltimore County - Essex Campus.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
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.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
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.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Chapter 1: Introduction to Computers, Problem Solving, and Programming
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1 Overview of Programming and Problem Solving
Computer System and Programming
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Computer Science I CSC 135.
Chapter 1 Overview of Programming and Problem Solving
What is Computer Programming?
ICS103 Programming in C 1: Overview of Computers And Programming
Presentation transcript:

CS 115 Chapter 1 Overview of Programming and Problem Solving

Chapter 1 Every programmer needs a mental model of a computer Every program does: input / process / output von Neumann model - the "stored program" concept

Computer Hardware CPU - central processing unit Where decisions are made, computations are performed, and input/output requests are delegated Main Memory Stores information being processed by the CPU short-term (volatile) Secondary Memory (Mass Storage) Stores data and programs long-term

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

Memory (RAM) a memory cell (also called a word) has an address, has contents Contents expressed in bits / bytes - binary code Holds a value which may be data, may be an instruction data retrieval = a "copy" not a "cut"

Memory Cells AddressContents H X RTV

Secondary Storage files - source files, data file, output file hard disk, floppy, CD, flash memory stick slower than RAM, and cheaper per byte usually much larger capacity than RAM Units of capacity - Kilobyte, Megabyte, Gigabyte, Terabyte

Languages Machine languages take a step, lift arm, grasp knob, turn knob... Assembly languages LEAVE through DOOR High-level languages "get outta here!"

Programming Languages Machine Language Most fundamental language of the computer, the one the CPU "understands" Unique for each processor type, so not "portable" Binary 0s and 1s that specify what to do

A Program in Machine and Assembly Language

High Level Languages Are portable Programmer writes program in language similar to natural language (human) Examples -- FORTRAN, COBOL, Pascal, Ada, Modula-2, C++, Java Most are standardized by ISO/ANSI to provide an official description of the language

Software Development Analyze and specify the problem Design the algorithm Implement in code Testing Maintenance

Software Development Problem Analysis Identify data objects Determine Input / Output data Constraints on the problem Design Decompose into smaller problems Top-down design (divide and conquer) Develop Algorithm (Desk check) Algorithm refinement (Pseudocode)

Software Development Method Implementation Converting the algorithm into programming language Testing Verify the program meets requirements System and Unit tests Maintenance All programs undergo change over time

A Tempting Shortcut? GOAL THINKING CODE REVISE DEBUG TEST CODE Shortcut?

Translators and Tools Assemblers for assembly languages Compilers for high-level languages IDE (integrated development environment) compiler editor (creates text format files) linker loader debugger

Translation Syntax - the rules governing the formation of statements in the language Spelling Order of words, statements Punctuation Semantics – meaning of the statement What does it DO? What action does the computer do when the statement is executed?

Processing a Program Editor used to enter the program Creates source program file Compiler translates the source program Displays syntax errors Creates (usually) temporary object code Linker to combine object file with other object files (like library code) Creates final executable program (.exe) Loader copies exe file into RAM to be run by machine

Three C++ 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

Ethics Responsibility comes with knowledge hacking piracy data theft and data privacy Responsibility to develop programs without errors

Some C++ History 1972 : 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” 1983 : Name C++ first used 1998 : ISO/ANSI standardization of C++

Objects in a hierarchy

Some C++ History Dennis Ritchie Bjarne Stroustrup

Problem Solving Techniques Ask questions -- about the data, the process, the output, error conditions Look for familiar things -- certain situations arise again and again Solve by analogy -- it may give you a place to start Use means-ends analysis -- determine the I/O and then work out the details

More Problem Solving Techniques Divide and conquer -- break up large problems into manageable units Building-block approach -- can you solve small pieces of the problem? Merge solutions -- instead of joining them end to end to avoid duplicate steps Overcome mental block -- by rewriting the problem in your own words

Case Study: Converting Miles to Kilometers Problem Your summer surveying job requires you to study some maps that give distances in kilometers and some that use miles. You and your coworkers prefer to deal in metric measurements. Write a program that performs the necessary conversion.

Case Study Analysis The first step in solving this problem is to determine what you are asked to do. You must convert from one system of measurement to another, but are you supposed to convert from kilometers to miles, or vice versa? The problem states that you prefer to deal in metric measurements, so you must convert distance measurements in miles to kilometers.

Data Requirements Problem Input milesdistance in miles Problem Output kmsthe distance in kilometers Relevant Formula 1 mile = kilometers

Design an Algorithm that solves the problem Algorithm (Pseudocode) 1. Get the distance in miles. 2. Convert the distance to kilometers. 3. Display the distance in kilometers. Algorithm Refinement 2.1 The distance in kilometers is times the distance in miles Desk check!

Miles to kilometers Implementation

Testing Test with input data for which you can easily determine the expected results E.g. 10 miles should convert to kilometers