Chapter 4 Programming Concepts Dept. of Computer Engineering Khon Kaen University.

Slides:



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

Lecture 1: Overview of Computers & Programming
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
Chapter 1 - An Introduction to Computers and Problem Solving
ICS103 P ROGRAMMING IN C L ECTURE 1: O VERVIEW OF C OMPUTERS & P ROGRAMMING.
COSC 120 Computer Programming
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
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.
Computers: Tools for an Information Age
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
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.
Course: Introduction to Computers
Systems Software Operating Systems.
COS120 Software Development Using C++ AUBG Fall semester 2010
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CS1044 – Intro. To Programming in C++ Dr. Craig A. Struble.
CS 115 Chapter 1 Overview of Programming and Problem Solving.
Lesson 4 Computer Software
Chapter 1 Overview of Computers and Programming. 1-1 Outline 1.1 ELECTRONIC COMPUTERS THEN AND NOW 1.2 COMPUTERS HARDWARE 1.3 COMPUTERS SOFTWARE 1.4 THE.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition 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.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Chapter Lead Black Slide Powered by DeSiaMore Powered by DeSiaMore.
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
4 - 1 Copyright © 2006, The McGraw-Hill Companies, Inc. All rights reserved.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CISC105 General Computer Science Class 1 – 6/5/2006.
Chapter 1: An Overview of Computers and Programming Languages
Systems Software Operating Systems. What is software? Software is the term that we use for all the programs and data that we use with a computer system.
Overview of Programming and Problem Solving Textbook Chapter 1 1.
Lead Black Slide. © 2001 Business & Information Systems 2/e2 Chapter 5 Information System Software.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Software Development Method Reference : Problem Solving & Program Design in C ; Jeri R.Hanly, Elliot B.Koffman.
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
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
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
Chapter 4 Software. Introduction Program: is a set of sequence instructions that tell the computer what to do. Software: is a collection of programs,
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Introduction  Program: Set of sequence instruction that tell the computer what to do.  Software: A collection of programs, data, and information. 
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
CHAPTER 1 OVERVIEW OF COMPUTER AND PROGRAMMING 1.1 Electronic Computer Then and Now 1.2 Computer Hardware 1.3 Computer Software 1.4 The Software Development.
Professor John CarelliKutztown University Computer Science Department Computer Science I CSC 135.
Chapter 1: Introduction to Computers, Problem Solving, and Programming
Engineering Problem Solving With C An Object Based Approach
Chapter 1: An Overview of Computers and Programming Languages
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Introduction to Computers and Java
Course: Introduction to Computers
Chapter 1: An Overview of Computers and Programming Languages
Computer Science I CSC 135.
Computers: Hardware and Software
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.
ICS103 Programming in C 1: Overview of Computers And Programming
Presentation transcript:

Chapter 4 Programming Concepts Dept. of Computer Engineering Khon Kaen University

Major Concepts Computer Software Processing a high-level language program The software development method Applying the software development method Professional ethics for computer programmers

Computer Software Two major categories of software System software: operating systems Example: Windows, Apple OS X, Unix Application software Example: Microsoft PowerPoint, Microsoft Word Processing

Operating Systems Communicating with the user Managing allocation of resources Collecting input from input devices Conveying program output to output devices Accessing data from secondary storage Writing data to secondary storage

Some Widely Used OSs Command-Line Interface Unix MS-DOS Linux Graphical User Interface Mac OS X Windows 9x, NT, 2000, Me, XP UNIX + X Windows System Linux + X Windows System

OSs: Command-Line Interface This OS displays a brief message called prompt that indicates readiness to receive input. The user then types a command at the keyboard Then, the OS finds the executable program that corresponds to the command and then invoke the program

MS-DOS Command Interface C:\>dir temp/w Volume in drive C has no label. Volume Serial Number is 8835-FDA8 Directory of C:\temp [.] [..] [C#] [DirectX9] [License] SSHSecureShellClient exe 1 File(s) 6,070,272 bytes 5 Dir(s) 28,122,365,952 bytes free

UNIX Command Interface gear.kku.ac.th:/home/krunapon/ public_html %ls Kanda.htm index.html srProjs03.zip DotNET index-en.html pubs

OSs: Graphical User Interface (GUI) The GUI interface provides the user with a system of icons and menus To issue commands Users move the mouse cursor to point to the appropriate icon or menu selection Users then click a button once or twice

OSs: GUI (Cont.) Icons are pictures that represent computer resources and files, such as printers, documents, and programs You double-click an icon to choose (activate, launch) a program The Windows OS offers two unique tools Taskbar Start button

IconsWindow control buttons Scroll box Scroll bar DesktopTask barStart menuStart button Dialog box Program running in a window

Application Software A program used for a specific task such as word processing, accounting, or database management Application software tells the computer how to accomplish tasks the user requires, such as creating a document Programmers use programming languages to write most application software

Programming Languages Commands or lists of instructions for a computer to execute Types of programming languages Machine language: binary numbers directly understood by a computer Assembly language: in the form of mnemonic codes and variable names. converted to machine codes by the assembler and linker

Programming Languages (Cont.) Types of programming (Cont.) High-level language A programming language that combines algebraic expressions and English words Converted to machine codes by a compiler or an interpreter or a compiler Examples: BASIC, C, C++, COBOL, FORTRAN, Java, Lisp, Pascal

Assembler & Linker

Machine and Assembly Languages Memory AddressMachine Language Instructions Assembly Language Instructions RTV A ADD B STO A HLT A = A + B

Object-Oriented Programming (OOP) Programs are organized as cooperative collections of objects What is an Object? An object is a software bundle of related properties Software objects are used to model real- world objects you find in everyday life Objects communicate with one another by exchanging messages

OOP (Cont.) Objects that share common properties can be grouped into classes Classes can be organized into a hierarchy of subclasses and superclasses A class inherits state and behavior from its superclass. OOP languages C++, Java, C#

Classes and Objects Class Automobile Object1Object2 ColorBronzeSilver MakerToyotaHonda ModelViosCity Year

A Class Hierarchy Vehicle has: driver’s seat four wheels Truck has: driver’s seat four wheels Truck bed Automobile has: driver’s seat four wheels passengers’ seats Sports car has: driver’s seat four wheels rear spoiler

Processing a High-Level Language Programming A source file is a file program written in a high-level language Syntax is the grammar rules when writing a source file Compiler translates the high-level language program (a source file) to file containing the machine language An object file is an output of the compiler.

Executing a Program To execute a program, the CPU Must load each program instruction in memory Send out the command signals required to carry out the instruction The program can have both input data and program output

Input Data Input data is the data that is the input of the program During execution, data can be entered into memory and manipulated in some specific way. Special program instructions are used for accepting the input data from the users and this input data then is loaded into memory

Program Output After input data has been processed, Special program instructions for displaying or printing values in memory can be executed to Display the program results on a computer monitor Save the program results in a file

An Execution of a Program

Major Concepts Computer Software Processing a high-level language program The software development method Applying the software development method Professional ethics for computer programmers

Software Development Method 1. Specify the problem 2. Analyze the problem 3. Design the algorithm to solve the problem 4. Implement the algorithm 5. Test and verify the completed program 6. Maintain and update the program

SW Development (Cont.) 1. Specifying the problem requirement State the problem clearly and unambiguously Have a clear understanding of what is required for its solution 2. Analyzing the problem Identifying the problem inputs and outputs Identifying any additional requirements or constraints on the solution Develop a list of problem variables and their relationships

SW Development (Cont.) Daily problem: I want to know the total cost of 5 kilograms of mangoes that are 30 baht per kilogram Step 1. Specify the problem requirement Translate the daily problem into the computer programming problem Compute and display the total cost of mangoes given the number of kilograms of mangoes purchased and the cost per kilogram of mangoes.

SW Development (Cont.) Step 2. Analyze the problem Underline phases in the problem statement that identify the inputs and output Compute and display the total cost of mangoes given the number of kilograms of mangoes purchased and the cost per kilogram of mangoes.

SW Development (Cont.) Step 2. Analyzing the problem Problem Inputs Quantity of mangoes purchases (in kilograms) Cost per kilogram of mangoes (in Baht per kilogram) Problem Outputs Total cost of mangoes (in Baht)

SW Development (Cont.) Step 2. Analyzing the problem Develop a list of formulas that specify relationships between the inputs and the outputs Total costs of mangoes = Cost per kilogram x the number of kilograms of mangoes

SW Development (Cont.) Step 2. Analyzing the problem Sometimes we may need to make certain assumptions or simplifications to derive these relationships The process of modeling a problem by extracting the essential variables and their relationships is called abstraction

SW Development (Cont.) Step 3. Designing the algorithm to solve the problem Develop a list of steps called algorithm to solve the problem An algorithm is usually designed based on the divide and conquer approach or the top-down design approach

Divide and Conquer Divide the problem into the major steps or sub-problems that need to be solved Conquer each sub-problem and then combine the solutions of sub-problems to form the solution of the original problem. This process is called algorithm refinement Sub-problems are further divided until they are easily solved by program code

SW Development (Cont.) Step 3. Designing the algorithm Algorithm of a Sample Problem 1. Get the input data 2. Perform the computations 3. Display results Then verify that the algorithm solves the problem as intended by desk-checking Carefully perform each step (or its refinement) just as a computer would and verify that the algorithm works as expected

SW Development (Cont.) Step 4. Implementing the algorithm Write the algorithm as a program coding Convert each algorithm step into one or more statements in a programming language Step 5. Test and verify the completed program Compile and run the program Test the program with different data sets Ensure that the program works correctly for the given problem specification

SW Development (Cont.) Step 6. Maintain and update the program Modify a program to remove previously undetected errors Keep the program up-to-date as government regulations or company policies change Coding Hints Make very small additions/changes and test the partly finished code Don’t write a complete program, and then expect it to work first time

Applying the SW Development Case study: Converting miles to kilometers Problem: Your summer survey 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 measurements. Instruction: Write a program that performs the necessary conversation

Problem Analysis Since you prefer to deal in metric measurements so you must convert distance measurements in miles to kilometers Therefore, the problem input is distance in miles and the problem output is distance in kilometers

Problem Analysis (Cont.) To write the program, you need to know the relationship between miles and kilometers. One mile is equal to kilometers

Problem Analysis (Cont.) Data requirements Problem input Miles the distance in miles Problem output Kmsthe distance in kilometers Relevant formula 1 mile = kilometers

Algorithm Design Steps in the algorithm 1. Get the distance in miles 2. Convert the distance to kilometers 3. Display the distance in kilometers Now decide whether any step of the algorithm needs further refinement

Algorithm Design (Cont.) Algorithm refinement The distance in kilometers is times the distance in miles Algorithm with refinements Step 1. Get the distance in miles Step 2. Convert the distance in kilometers: 2.1 The distance in kilometers is times the distance in miles Step 3. Display the distance in kilometers

Algorithm Design (Cont.) Desk-checking the algorithm If step 1 gets a distance of 10.0 miles Step 2.1 would convert it to 1.609x10.00 = kilometers And then step 3 should display number “16.09” as a program output

Implementation // Miles.cpp // Converts distance in miles to kilometers. #include // class for stream input/output using namespace std; // use the standard namespace int main() // start of main function { const float km_per_mile = 1.609; // km in a mile float miles, // input: distance in miles kms; // output: distance in kilometers // Get the distance in miles. cout << "Enter the distance in miles: "; cin >> miles; // Convert the distance to kilometers. kms = km_per_mile * miles; // Display the distance in kilometers. cout << "The distance in kilometers is " << kms << endl; return 0; } Enter the distance in miles: 10.0 The distance in kilometers is 16.09

Professional Ethics for Computer Programmers Computer programmers and software engineers should follow certain standards of professional conduct: Privacy and misuse of data Computer hacking Plagiarism and software piracy Misuse of a computer resource