1 Introduction to Computers and Programming Essential feature of a computer is the separation of operations and data.

Slides:



Advertisements
Similar presentations
Senem Kumova Metin Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming.
Advertisements

Chapter 1 An Overview of Computers and Programming Languages.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
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.
COSC 120 Computer Programming
Chapter 1: An Overview of Computers and Programming Languages J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program.
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.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
Program Flow Charting How to tackle the beginning stage a program design.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Program Design
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.
Introduction to Computers and Programming
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
CS102 Introduction to Computer Programming
Introduction to Computers and Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
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.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
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.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
Programming Fundamentals1 Chapter 1 INTRODUCTION TO COMPUTER AND PROGRAMMING.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
The Programming Process Define the problem* Make or buy software? Design the program * Code (write) the program Test (debug) the program Document the.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
The Software Development Process
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.
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
Chapter 1 An Overview of Computers and Programming Languages.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
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.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
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.
Algorithms and Flowcharts
Chapter 1: Introduction to Computers and Programming
Evolution and History of Programming Languages
Chapter 1 Introduction 2nd Semester H
Java Programming: From the Ground Up
Chapter 1: An Overview of Computers and Programming Languages
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 2 Introduction to Programming
Chapter 1: Introduction to Computers and Programming
Programming Languages
Programming Fundamentals (750113) Ch1. Problem Solving
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Chapter 1 Introduction(1.1)
The Programming Process
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming Fundamentals (750113) Ch1. Problem Solving
Introduction to Computer Programming
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1: Preliminaries
ICS103 Programming in C 1: Overview of Computers And Programming
Programming Logic and Design Eighth Edition
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

1 Introduction to Computers and Programming Essential feature of a computer is the separation of operations and data.

2 Hardware Leibnizt 17 th Century (adding machine) Babbage 1835 Turing 1936 Post war: ENIAC 30 tons (needed external wiring) and EDSAC (first stored program) UK – based on Von Neumann Design Now similar design but speed in MIPS and BIBS rather than 6 – 10! The physical components  Accept input, Display output.  Store information.  Perform arithmetic and logical operations  Control sequence of system

3 The physical components INPUT OUTPUT Memory (RAM) Secondary Storage, Hard disk, Floppy, Zip, CD Arithmetic and logic unit (ALU) Control Central Processing Unit (CPU)

4 The Computer’s Core: CPU and Memory A collection of switches and relays Transforms information User provides input Computer follows instructions Returns output to user Each type understands specific instructions, Opcodes, (IBM or Mac) Communicates with the other parts of the computer.

5 RAM (Random Access Memory ) RAM most common type of primary storage RAM can store programs and data temporarily RAM has memory locations with unique addresses Computers can quickly retrieve from RAM RAM is volatile memory it is temporary and constantly changing. Power off — RAM is cleared, whether you saved it or not!, Save to secondary storage.

6 Addresses * Imagine a stack of letter boxes. Each box has a unique address. Each box has can contain some information (a byte). Each byte has 8 bits which can be a 0 or : Low High MemoryMemory Address :

7 Computer Software The programs Systems Applications Like English, programs written in a programming language have their own syntax. Unlike English there are no irregular verbs and exceptions to be learnt

8 Programming Languages Over 200 languages Language depends upon task Assembly, COBOL, Logo, C++, Pascal, FORTRAN, BASIC.

9 Programming languages (Cont)  Machine languages  Add contents of memory location 1 to contents of memory location 2  Horrid to write programs! Assembly  ADD 12  Needs an assembler to translate to machine language Opcode

10 Programming Languages (cont) Levels of Computer Languages: Low (long way from English) machine language, assembly High (Closer to English) COBOL, Pascal, FORTRAN, Logo, Basic Mid-level? C, C++

11 Programming Languages (cont) Procedural languages focus on tasks. Breaks programs down into sub-procedures. Pascal, Fortran. Object-Oriented languages (OOP) focus on data, looks at data and operations that are performed on the data. Java, Smalltalk Special Languages (very high) Prolog, Lisp

12 However C ++, COBOL, FORTRAN, Pascal, BASIC, Prolog etc. Computer Can’t Understand English! OR Computer Understand Machine language.

13 Translation/Interpretation Translation to Machine Language Interpreter Compiler/linker Assembler

14 Compilation Creating and executable file with C++ source code compiler - h-files used object code linked to libraries.exe file

15 Developing/Constructing Programs

16 Problem Solution and Software Development Phase I: Analysis, Design and Development. Phase II: Documentation Phase III: Maintenance

17 A Close Look at Phase I 1. Analyse/Solve the problem 2. Develop/Design a solution produce an algorithm 3. Code the solution 4. Test/Verify the program

18 A Close Look at Phase I Problem analysis and Solution finding Need a process of solving a problem and then getting the solution onto a computer. Initially YOU need to know how to solve a problem in English, before you can get a computer to tackle the problem. The problem is that computers do not understand English. You need to get the solution into a form the computer understands.

19 Problem Solving: generalized problem-solving approach 1.Understand the problem 1.Roughly sketch out 2.Identify inputs/outputs unknowns, assumptions. 3.Notation: sketch out ideas for variable names and types. 4.Sketch out any equations/relations that you know or that might be useful. 2.Devise a plan 1.Write the plan down! 2. Check the plan 3.Implement the Plan 1.Check the implementation 4.Examine Solution

20 1. Understand The Problem Draw a figure. What is the data, Try to introduce suitable variables. What sort of variables should they be? What is the unknown? What is known? Are there any conditions that need satisfying?  e.g. A grading program will have different grades according to exam scores. Are the conditions sufficient to determine the unknown? Or is it insufficient? Or redundant? Or contradictory? If not, what do you need to determine the unknown? Can you write the conditions down?

21 Output of Step 1 One or more pages of rough work, nothing formal Good idea of problem requirements Good idea of inputs, outputs, constants, conditions, assumptions.

22 2. Devise a Plan Find the connection between the data and the unknown.  You might need to consider separate problems if you can’t find an intermediate connection. You should eventually come up with a plan of the solution. Have you seen the problem before? Have you seen the same problem in a slightly different form? Do you know a related problem? Do you know a theorem that could be useful?  Pythagoras?

23 2. Devise a Plan Continued look at the unknown! And try to think of a familiar problem having the same or a similar unknown. Is there a problem related to yours and solved before. Can you use it? Can you use its method? Should you introduce some other element in order to make its use possible? Can you restate the problem? If you cannot solve the proposed problem, try to solve some related problem first. Can you solve a simplified form with particular conditions.

24 2. Devise a Plan Continued Can you imagine a more accessible related problem? A more general problem? A more special problem?  E.g. If you need to count the number of words in a file. Solve the sub-problem of counting the number of words on a line first. Can you solve a part of the problem? Keep only some of the conditions

25 2. Devise a plan continued Can you derive something useful from the data? Can you think of other data appropriate for determining the unknown? Can you change the unknown or the data, or both if necessary, so that the new unknown and the new data are nearer to each other? E.g. Change from one coordinate system to another, Did you use all the data? Did you use all the conditions?

26 Devise a plan continued Is there a different way of solving the problem. Can you use this to check your solution? is it better?

27 Output of Step 2 Top Down Design A formal written design. State inputs, outputs Write steps to process input unambiguously using a semi formal notation (PDL, Flowchart or structure diagram? Can you translate each step of the plan into C++ easily? No … Go back and refine Verification/testing procedures documented (A test table).

28 3. Coding the Solution Check code for each step Incrementally. Can you see clearly that the step is correct? Can you prove that it is correct? How would you prove it is correct? i.e. what are the tests you would use to prove your plan?

29 4. Examining the solution Check the result? Use tests identified in step 2. Can you use the solution, or the method, for some other problem?

30  So find a solution, write it down in English.  Write it down more formally in Pseudo-code (PDL), or as a structure diagram or a flow chart.  Start your programming environment and convert your pseudo-code to C++  Tell the computer to convert the C++ to machine language (compile)  Tell the computer to load the machine language into memory and execute (Run). Summary

31 Algorithms An algorithm is simply the technical word for your solution/Plan. It is the step by step sequence of instructions to complete a task it will consist of: Sequences Selection Iteration Invocation

32 Example of Top Down Design Making Cups of Coffee Problem: Make 10 cups of coffee Initial (Top) Plan Make 10 cups of coffee Refinement 1 Repeat 10 times Make a cup of Coffee End repeat

33 Example of Top Down Design Making Cups of Coffee Refinement 2 Repeat 10 times Put coffee in Cup Put boiling water in Cup End repeat

34 Example of Top Down Design Making Cups of Coffee Refinement 3 Repeat these tasks 10 times 1. Get mug out of cupboard 1. End Repeat 2. Get Coffee out of cupboard 3. Fill Kettle 4. Put Kettle on to boil 5. Repeat 10 times 1. Put Coffee in cup 2. If Kettle boiled put water in cup 3. If wanted Add milk 4. If wanted Add sugar 6. End repeat

35 Another Example Linear Search Problem: Find the largest number in a list of numbers.

36 Design Example Linear Search PDL call the 1st number largest call the 2nd number current 1 while we are not finished 2 if current > largest 4 label current as largest 5 call next number in the list current 6 repeat the while 7 output the largest

37 Linear Search Flowchart largest = first No Current = Second No Largest = Current Current > Largest? Current = Next No Any more numbers? Display largest No Yes Start Stop

38 Phase II Documentation Improve readability You remember Others understand Enables easy maintenance

39 What is documentation Your formal design paperwork. Should be detailed enough for any programmer to implement Comments (annotations) actually written into the code.

40 Phase III Maintenance Correction of problems after delivery Add features Adapt to changing needs. E.g. Y2K problem Needs good documentation!

41 What we are aiming for is Structured Programming Advantages Not one giant step, but breaks in to smaller and smaller chunks. Programmer concentrates on details Easy to do in teams Easy to keep track of development Creates more reliable and robust programs. Makes more possible reuse and extensibility.

42 Structured Programming Errors isolated Design written in code Improves reliability Minimizes risk of Failure Faster development Full documentation Maintainability

43 Writing Down Solution Designs Flowcharts Pseudo-code Structure Diagrams

44 Logical steps Written in English Language independent Labels Indenting for logical structures 1. begin game 1.1 display instructions 1.2 pick a number between 1 and repeat turn until number is guessed or seven turns are completed 2.1 input guess from user 2.2 respond to guess 3. end repeat 4. end game 4.1 display end message Pseudo-code/ PDL

45 Logical steps represented by standard symbols display instructions get number is number even? YesNo continue Flowcharts

46 Structure Diagrams Inventory Control Program Enter dataDo Calculations Display report 123

47 Summary No Magic Bullet Adopt good practice (structured programming) Apply Three Phases Phase I – analyse, develop algorithm, code test Phase II – Document Phase III - Maintain