Introduction to Computers and Programming History of computers What is a computer system? What is a software? What is programming? Different languages.

Slides:



Advertisements
Similar presentations
Chapter 1 An Overview of Computers and Programming Languages.
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Chapter 1 - An Introduction to Computers and Problem Solving
COSC 120 Computer Programming
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
Traffic Light Behavior IF A=1 AND B=0 Car Sensors B A.
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01.
Computing Components 01/26/11. Announcements & Reminders Programs 1 due Friday, 9/2/11 What is my late policy? Proxy Codes for Labs  You should be able.
Chapter 1 Program Design
Chapter 3 Planning Your Solution
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Computer Science I CS rmaclin
Introduction to computer: storing instructions and information.
CS102 Introduction to Computer Programming
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Exam 1: Review 1.History of computers 2.Fundamentals of computer architecture 3.Developing algorithms and programs 4.Variables and data types 5.User I/O.
1.1 1 Introduction Foundations of Computer Science  Cengage Learning.
Chapter 1 Engineering Problem Solving 1. Hardware and Software 2 A computer is a machine designed to perform operations specified with a set of instructions.
CS 0004 –Lecture 1 Wednesday, Jan 5 th, 2011 Roxana Gheorghiu.
Simple Program Design Third Edition A Step-by-Step Approach
COMPUTER SYSTEM.
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.
Programming 1 1. Introduction to object oriented programming and problem-solving.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 3: Requirements Specification, C++ Basics.
Developing a Solution How to create the computer-based solution for a real-world problem. 1.
What is a Computer? An, electrical machine, that can be programmed to accept data (input), process it into useful information (output) and store it away.
Introduction to Programming Using C Introduction to Computer Programming.
Developing a Solution How to create the computer-based solution for a real-world problem. 1.
Introduction to Computers and Programming 1. History of computers (4 slides) 2. What is a computer system? 3. What is a software? 4. What is programming?
Developing a Solution Getting past the panic of staring at a “blank sheet” of paper when solving a problem 1.
1. Understanding the Problem 2. Brainstorming 3. Drawing an I/O (Input/Output) diagram 4. 5-step Process (or: Small iPods Make Copying Tough) Developing.
Developing a Solution Getting past the panic of staring at a “blank sheet” of paper when solving a problem 1.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
1. Exam Topics Difference between computers and calculators John creates a new device. It will compute the orbit of all the planets in the solar system.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Introduction to programmable computing devices. What is a computer Computer: How was the computer developed/invented: A computer is a "reckoning" or computing.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Ch1 Introduction to Computers and Programming 1. History of computers (4 slides) 2. What is a computer system? 3. What is a software? 4. What is programming?
Lecture 5 1.What is a variable 2.What types of information are stored in a variable 3.Getting user input from the keyboard 1.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CS 1428 Foundations of Computer Science I. Two Main Components  Hardware  Physical media that uses electrical current to process instructions.  Software.
Topic Review for Exam 1 0.Infrastructure: You must be able to use MATLAB, Blackboard Exams, and Blackboard submissions 1. Computer Developing algorithms.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Introduction  Program: Set of sequence instruction that tell the computer what to do.  Software: A collection of programs, data, and information. 
Chapter 1 An Overview of Computers and Programming Languages.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
Introduction to Computer Programming using Fortran 77.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Computers and Programming
Control Unit Lecture 6.
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Course: Introduction to Computers
Computer Science I CSC 135.
Computers: Hardware and Software
Computer components is a programmable machine that receives input, stores and manipulates data, and provides output in a useful format. Computer The computer.
ICS103 Programming in C 1: Overview of Computers And Programming
Presentation transcript:

Introduction to Computers and Programming History of computers What is a computer system? What is a software? What is programming? Different languages Compiled vs. interpreted 1

History of Computers Computers are programmable. The first calculators were not programmable, hence not considered computers. Computers are general purpose machines. Calculators are NOT. 2 History 1/4

1854 (~150 years ago) Pioneer of modern computer! 3 Babbage’s difference engine Device to subtract adjacent values in a column of numbers. Created for engineers in charge of creating tables of logarithms and trigonometric functions. History 2/4

1943 (~70 years ago).. came Colossus Primarily used for breaking the German codes during World War 2. It would crack Enigma Codes (codes that were cracked by exhaustively shifting text by arbitrary amounts). For example: ‘Zsszbj zs 9599’ would be ‘Attack at 0600’ 4 History 3/4

Finally, the von Neumann Architecture… The Von Neumann computer architecture is mostly what we still use today. The architecture separates a computer in 3 major parts: The Central Processing Unit (CPU) The computer memory The Input/Output (I/O) devices 5 CPU + memory Screen=output Speakers=output Mouse=input Keyboard=input ? ? Knob=input History 4/4

Software and programming? Microsoft Word, Excel, Guitar Hero, the address book in your cell phone, the electronic that starts a car, the avionics in an airplane… are all software that were written by people. Programming is the act of writing logical instructions that will be executed when people use the software. It is as difficult as learning to speak a foreign language, since the programmer is constrained to the vocabulary (specific keywords) and grammar (exact syntax) of programming. 6

A computer system today Keeping the von Neumann architecture, today’s computing systems combine both hardware and software. Hardware (i.e. what’s hard and can break..): mouse, keyboard, monitor, hard disk, printer, CD, DVD. Software i.e. the programs that describe the steps we want the computer to perform. 7

Quiz1 An actual DVD is a: a) hardware b) software The content on a Microsoft Office DVD is most likely: a) hardware b) software 8

Categories of software Software contains the instructions the CPU uses to run programs. There are several categories, including: Operating systems (OS) – manager of the computer system as a whole Software applications – commercial programs that have been written to solve specific problems Language compilers - to ‘translate’ programs written by people into something understandable by the machine (sometimes not needed) 9

Quiz2 Which type of software are these? ________ 10

Quiz3 Which type of software is this?____________ 11

Generations of Languages used to write software 1) Machine language – also called binary language. Sequence of 0’s and 1’s. 2) Assembly language – each line of code produces a single machine instruction (add, subtract…), see bottom of page 11. 3) High-level language – slightly closer to spoken languages. 12 addb,c adda,b a= a + b + c; This line does the same as the two above.

Quiz4 Order these types of languages in the order they came out? ____assembly language ____machine language ____high-level language 13

Finally… MATLAB Is an interpreted language – does not require compilation, but it does have a compilation step hidden from the user. Has an interactive environment – “In the MATLAB environment, you can develop and execute programs that contain MATLAB commands. You can execute a MATLAB command, observe the results, and then execute another MATLAB command that interacts with the information in memory, observe its results and so on.” 14

Internet vs. WWW? Internet is the “boss” of all communication tools, including www but also servers, etc… 15

Wrapping Up Computers vs. Calculators? Evolution of computers from WW2? Von Neumann Architecture? Hardware vs. software? Types of languages? 16

Developing a Solution General Idea Five-step Process Example Wrapping up 17

General Idea: Give you methodology to layout a plan to develop a solution for a given problem (task). In EGR115, most tasks will be: “Develop a program that ……” As a programmer, keep in mind there are 2 sides to a software The person who writes the software: the programmer The person who uses the software: the user (aka client) As you (the student) develop software, you will constantly jump back and forth between the two roles.

The 5 step process Follow these steps in order: 1. State the problem clearly 2. Identify the givens vs. the results wanted This will be referred as the I/O diagram 3. Manually solve the problem 4. Computerize the solution 5. Test, test, test!!! 19

Step 1. State the problem However easy the problem may seem, it is crucial to fully understand the problem, and clarify details. It can help to put the problem in writing. For example: Write a program that “Computes the area of a triangle” This might bring up questions – like “what do I know about the triangle?” 20

Step 2. Identify the I/O What do you know about the problem? How do you want to solve it? 21 side 1 side 2 angle height base

Step 2. Identify the I/O Remember the Von Neumann architecture? CPU + memory + inputs/outputs devices The I/O diagram determines which input and output devices the software uses, as well as decide which inputs and output variables are used. The I/O diagram is a first step to organizing the brainstorming. 22

General frame of an I/O diagram Arrows indicate and names each given and result Purple boxes indicate which devices are used 23 ? ? ? ? ? ? ? ?

Applied to the area of triangle 24 AREA OF TRIANGLE Sides 1 and 2 Angle External interface – What DEVICE is used to enter the values of the givens Keyboard Each arrow represents the INPUTS (=GIVENS)

Applied to the area of triangle 25 COMPUTE THE AREA OF TRIANGLE Sides 1 and 2 Angle Keyboard Each arrow represents the INPUTS (=GIVENS) area Each arrow represents the OUTPUTS (=RESULTS)

Applied to the area of triangle 26 COMPUTE THE AREA OF TRIANGLE Sides 1 and 2 Angle External interface – What DEVICE is used to see the results Keyboard Each arrow represents the INPUTS (=GIVENS) Screen area Each arrow represents the OUTPUTS (=RESULTS)

Applied to the area of triangle Final I/O diagram 27 COMPUTE THE AREA OF TRIANGLE Sides 1 and 2 Angle Keyboard Screen area

Same problem: Option 2 28 COMPUTE THE AREA OF TRIANGLE Sides 1 and 2 Angle Printer Different input/output devices area 28 Microphone

… or option 3 … 29 COMPUTE THE AREA OF TRIANGLE base height Screen area 29 Keyboard Different Inputs

Some Other More Complex Examples (and yet, the I/O is not so complex) 30 ATM MACHINE

Some Other More Complex Examples (and yet, the I/O is not so complex) 31 ATM MACHINE pin Deposit/with- draw/transfer… Touch Screen/ pin pad Account number Card

Some Other More Complex Examples (and yet, the I/O is not so complex) 32 ATM MACHINE money Money Slot pin Deposit/with- draw/transfer… Touch Screen/ pin pad Account number Card

Some Other More Complex Examples (and yet, the I/O is not so complex) 33 ATM MACHINE money Money Slot pin Deposit/with- draw/transfer… Touch Screen/ pin pad Account number Card receipt Receipt Slot

Step3. Manually Solve Problem Solving the area of a triangle is obvious (right?) Height = 3 in Base = 2 in Area = ½ * 2 * 3 = 3 in 2 34

Step 4 and Step 5 These steps require the use of a computer to type ‘lines of code’ and test the program. Realize that none of the steps before did this. In short: Step 4 – Computerize the solution a) layout the algorithm. b) Write down the code that implements the algorithm. Step 5 – Test the software created

Remember: “SIMCT” (or: Small iPods Make Copying Tough) 1. SState the problem (clarify it if need be) 2. IIdentify the Inputs and Outputs 3. M Manually solve the problem 4. CComputerize the solution 1. Layout the algorithm 2. Provide the code that implements the algorithm 5. Ttest, Test, TEST!! 36

1. SState the problem (clarify it if need be) 2. IIdentify the Inputs and Outputs 3. MManually solve the problem 4. CComputerize the solution 1. Layout the algorithm 2. Provide the code that implements the algorithm 5. TTest, Test, TEST!! Remember: “SIMCT” (or: Small iPods Make Copying Tough) 37 Note: I and M are sometimes reversed. You may need to decide what method you will use to solve the problem before you can determine what inputs are needed and what outputs will be provided. In fact, sometimes the problem being solved gets changed. But we will assume the standard SIMCT model.

Developing a Solution Complete Example Development of software which finds the roots of any quadratic equation: ax 2 + bx + c = 0 38

1: State the problem The client says: “I want a computer program that will find the roots of any quadratic equation” 39

1 (cont.): The programmer wonders: Any quadratic equation? Inputs: What if the coefficient “a” is 0? Outputs: What if the roots are imaginary? And the client re-considers.. 40

1 (cont.): Client clarifies his requirements: “I want a computer program that will find the REAL roots of a quadratic equation for all REAL coefficients a, b, and c such that a≠0.” This shows a much more thorough consideration of the problem. 41

2: Identify Inputs/Outputs What are the inputs for this problem? In other words, what information is needed FROM OUTSIDE THE PROGRAM for the desired program to solve the problem? In our programs, these inputs typically come from the user – but they don’t have to. Sensors and other programs can provide information, too. 42

2 (cont.): Inputs, continued… The only information needed from outside the program are the values of the coefficients: a? b? c? 43

2 (cont.): Outputs: - The roots (x 1, x 2 ), if real. - Message if roots are imaginary. - Error if the user inputs bad values. 44

2 (cont.): Final I/O diagram: 45 *** magic *** Coefficients a,b and c Roots/ error message screenKeyboard

Step 3: Manually solve the problem Not always practical to actually solve the problem… e.g. can you manually launch the shuttle? But… a programmer must be able to solve the problem manually, assuming all the time and resources necessary were available. Otherwise, how could a programmer tell the computer how to do it??? 46

3 (cont.): 47 Test case #1: enter a valid case ( orials/math-worksheets-for-mean- mode-median-6th-grade.html ) orials/math-worksheets-for-mean- mode-median-6th-grade.html

3 (cont.): 48 Test case #2: enter 0 for a  expect an error message Test case #3: enter a=4, b=-2, c=0  expect "imaginary roots" message

4: Computerize 4.1 Algorithm Describe the steps taken when the problem was manually solved. This is more difficult than it seems. Humans perform actions subconsciously – we’re not even aware we are doing them! 49

4.1 (cont.): Layout the algorithm in “skeleton” form: % Collect the inputs from the user % Apply the inputs to the quadratic formula % Display the results 50

4.1 (cont.): Now, “flesh it out” % Collect the inputs from the user % Print error message if bad inputs % Apply the inputs to the quadratic formula % Compute the discriminant (b 2 -4ac) % If discriminant < 0 % display ‘Imaginary roots’ % Otherwise % compute real roots % Display the results 51

4.2: code For each step of the algorithm, write code (in this class, MATLAB code) that will perform the actions you have specified. Avoid proceeding to the next step until you feel certain the step has been accomplished. It is important to test as you go. (Actual coding steps will be learned this semester) 52

5: test, Test, TEST!!! It is provably impossible to write a computer program to test another arbitrary computer program for correctness. And it’s usually too time consuming to write a program that specifically tests the program we’re writing – so we resort to manual testing. For complicated programs, it is not possible to test a program too thoroughly because it is not possible to test all inputs. And it may be worth writing that test program after all… Choose inputs to maximize confidence that the solution written will work correctly. 53

5 (cont.): For a quadratic solver, each set of input should be tested, which means: 54 a<0, b<0, c<0 a<0, b<0, c=0 a 0 a<0, b=0, c<0 a<0, b=0, c=0 a 0 a 0, c<0 a 0, c=0 a 0, c>0 a=0, b<0, c<0 a=0, b<0, c=0 a=0, b 0 a=0, b=0, c<0 a=0, b=0, c=0 a=0, b=0, c>0 a=0, b>0, c<0 a=0, b>0, c=0 a=0, b>0, c>0 a>0, b<0, c<0 a>0, b<0, c=0 a>0, b 0 a>0, b=0, c<0 a>0, b=0, c=0 a>0, b=0, c>0 a>0, b>0, c<0 a>0, b>0, c=0 a>0, b>0, c>0

Step5 (cont.) Of course, with human ingenuity, change the design of the program (i.e. modify the algorithm) to avoid some of these: % If no error condition (such as a equal 0) % then compute the roots % Otherwise, just print the error message With this sort of technique, we can avoid having to test nearly 1/3 of the possibilities! 55

Step5 (cont.) For a quadratic solver, each set of input should be tested, which means: 56 a<0, b<0, c<0 a<0, b<0, c=0 a 0 a<0, b=0, c<0 a<0, b=0, c=0 a 0 a 0, c<0 a 0, c=0 a 0, c>0 a=0, b<0, c<0 a=0, b<0, c=0 a=0, b 0 a=0, b=0, c<0 a=0, b=0, c=0 a=0, b=0, c>0 a=0, b>0, c<0 a=0, b>0, c=0 a=0, b>0, c>0 a>0, b<0, c<0 a>0, b<0, c=0 a>0, b 0 a>0, b=0, c<0 a>0, b=0, c=0 a>0, b=0, c>0 a>0, b>0, c<0 a>0, b>0, c=0 a>0, b>0, c>0

% Collect the inputs from the user % If no error condition % Compute the discriminant (b 2 -4ac) % If discriminant < 0 % display ‘Imaginary roots’ % Otherwise % compute real roots % Display the results % Otherwise % Print error message 57

% Collect the inputs from the user a = input(‘Enter coefficient a: ’); b = input(‘Enter coefficient b: ’); c = input(‘Enter coefficient c: ’); % If no error condition if a~=0 %means a not equal to zero, could have done (a 0) % Compute the discriminant (b 2 -4ac) discriminant = b^2-4*a*c; % If discriminant < 0 if discriminant<0 % display ‘Imaginary roots’ disp(‘Imaginary Roots’) % Otherwise else % compute real roots x1 = (-b + sqrt(discriminant)) / (2*a); x2 = (-b - sqrt(discriminant)) / (2*a); % Display the results fprintf(‘x1 = %.2f and x2 = %.2f\n’,x1,x2) end % Otherwise else % Print error message disp(‘error: a invalid’) end 58

Wrapping Up What are the 5 steps? 1. State the problem Do research if the problem is not clear enough 2. Identify the Inputs/Outputs (Givens/Results) Create an I/O diagram Which devices are used for each side? 3. Manually solve the problem 4. Computerize the solution 4.1 Set up the algorithm 4.2 Code 5. test, Test, TEST!!! 59