Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.

Slides:



Advertisements
Similar presentations
4/23/2015Engineering Problem Solving with C++ second edition, J. ingber 1 Engineering Problem Solving with C++, Etter/Ingber Chapter 1.
Advertisements

Lecture 1: Overview of Computers & Programming
INTRODUCTION OF COMPUTER
ENGR2216 FORTRAN PROGRAMMING FOR ENGINEERS. Chapter 1 The computer CPU MEMORY INPUT/OUTPUT DEVICES DATA REPRESENTATION BINARY SYSTEM OCTAL & HEXADECIMAL.
The Binary Machine Modern high-level programming languages are designed to make programming easier. On the other end, the low level, all modern digital.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
The Analytical Engine Module 6 Program Translation.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
COMP 14 Introduction to Programming
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Topic 1: Introduction to Computers and Programming
Introduction to Computers and Programming. Some definitions Algorithm: Algorithm: A procedure for solving a problem A procedure for solving a problem.
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 Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
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.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
CSCI 125 & 161 Lecture 2 Martin van Bommel. Hardware vs Software Hardware - physical components you can see and touch –e.g. processor, keyboard, disk.
CMPT 120 How computers run programs Summer 2012 Instructor: Hassan Khosravi.
Topics Introduction Hardware and Software How Computers Store Data
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming 1.
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.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
Lesson 1b: Computer Systems and Program Development CPS118.
Chapter 1: Preliminaries. Objectives In this chapter, you will learn about: Unit analysis Exponential and scientific notations Software development Algorithms.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
Computer Programming I. Today’s Lecture  Components of a computer  Program  Programming language  Binary representation.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Introduction to Computer Systems and the Java Programming Language.
What is computer hardware? Computer hardware are the physical components of the computer.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Programming Fundamentals How to Program in C++ How to Program in C++
Computer Science 101 Computer Systems Organization.
Computer Organization. The digital computer is a digital system that performs various computational tasks Digital computer use binary number system which.
Computer Systems. Bits Computers represent information as patterns of bits A bit (binary digit) is either 0 or 1 –binary  “two states” true and false,
Chapter 1 Introduction. Components of a Computer CPU (central processing unit) Executing instructions –Carrying out arithmetic and logical operations.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
CS 125 Lecture 2 Martin van Bommel. Hardware vs Software Hardware - physical components you can see and touch –e.g. processor, keyboard, disk drive Software.
Chapter 1 An Overview of Computers and Programming Languages.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
1 Chapter 1 Background Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter I: Introduction to Computer Science. Computer: is a machine that accepts input data, processes the data and creates output data. This is a specific-purpose.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 1: Introduction to Computers and Programming.
The Study of Computer Science Chapter 0
Java Programming: From the Ground Up
Chapter 1: An Overview of Computers and Programming Languages
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
Introduction to Programming
The Study of Computer Science Chapter 0
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
The Study of Computer Science
Computer Electronic device Accepts data - input
The Study of Computer Science Chapter 0
Presentation transcript:

Introduction to Computers and Programming

Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such a procedure, or method Computer Science: –Finding solutions to problems with the aid of computers –The study of algorithms

Computer science: what we study Properties of algorithms –Mathematical properties –Comparative efficiency: time & space tradeoffs Implementation of algorithms –Programming concepts –Programming languages Applications –What kind of problems can we solve? –What is the best way to solve a particular problem?

Hardware Physical parts of a computer system Major components include: –CPU –Memory –Peripheral devices

CPU CPU consists of the control unit, the ALU, and registers –registers: high-speed memory cells –ALU: arithmetic logic unit; performs calculations –control unit: copies data & instructions from memory, decodes instructions and follows them

Main memory Stores data & instructions in bit form –data: information to be processed –instructions: commands for computer to follow –bits: binary digits; two states represented as 1 or 0 Memory is organized into 8-bit groups called bytes Each byte has its own unique address

Memory representation Each instruction or piece of data must be stored in one or more bytes of memory The arrangement of 1s and 0s in each 8-bit byte can be interpreted as code representing a single instruction or data item Many data items and instructions require more than one byte of memory; we’ll see why later

Memory size We typically discuss memory in increments of millions (megabytes) or billions (gigabytes) In fact, since the fundamental building-block of memory is the byte, which is in turn based on the bit, the actual size of what we call a megabyte isn’t really a million bytes, but the closest power of 2: 2 20, or 1,048,576 Likewise, a gigabyte is actually 2 30 bytes, which is 1,073,741,824

Peripheral devices Mass storage devices, aka secondary memory; characteristics: –Most require mechanical motion (primary memory is all electronic) –portable media –large capacity –non-volatile –long-term storage for data & instructions

Peripheral devices Input/output (I/O) devices –move data & instructions into or out of memory –communication with memory is typically one-way –input devices include mice, keyboards, scanners –output devices include monitors, speakers, printers Both I/O and storage devices have controllers to coordinate their actions with the computer’s actions

Software Consists of programs that can run on a computer –Applications programs –System programs A program is a set of instructions Data are the raw material: letters and numbers, for example

Character data representation Bit patterns are used to represent characters and symbols ASCII is a code system that matches 8-bit patterns with natural language symbols, such as letters, numbers, and punctuation marks; a total of 256 characters (2 8 ) can be represented Unicode, a 16-bit system, is used in Java: this provides support for multiple languages and alphabets

Integer data representation Integers, or whole numbers, are represented using the binary, or base 2, numbering system As in the more familiar base 10, or decimal notation, a 0 digit represents a placeholder; other digits should be multiplied by the corresponding power the base, starting with the 0th power for the rightmost digit, the 1st power for the next one, the 2nd for the next, etc. The sum of the digits multiplied by their respective base powers is the value of the number

Decimal example The number 12,486 can be read (left to right) as: (1 x 10 4 ) + (2 x 10 3 ) +(4 x 10 2 ) + (8 x 10 1 ) + (6 x 10 0 ) = For binary numbers, the principle works the same, except that only 1s and 0s are used, and the digit at each place is multiplied by 2 instead of 10; the sum is still the value (in base 10) of the number

Binary example The number can be read as: (1 x 2 7 ) + (1 x 2 6 ) (1 x 2 2 ) + (1 x 2 1 ) + 0 = = Using binary representation requires several more digits than does decimal The largest number that can be represented in 8 bits is , or If one bit is reserved for the sign (positive or negative), than the magnitude of the number is restricted to  ( )

Integer representation The number of bits used determines the magnitude of the numbers that can be stored Signed numbers have more restricted magnitude than unsigned numbers

Representing real numbers Like integers and characters, real numbers are stored in binary form Unlike integers, real numbers are represented using scientific notation: –in decimal, the number can be represented as x 10 4, abbreviated e4 –similarly, is represented as 2.5e-4

Representing real numbers In computers, binary notation is used Since binary numbers are composed of 0s and 1s, any number can be represented with a whole part of 1; so it isn’t necessary to store a number’s whole part, as it is always 1 Therefore, several bits can be set aside to represent the fractional part of the mantissa, and several more bits can be used to represent the exponent of the radix, 2

Representing real numbers Both the mantissa (its fractional part) and the exponent are stored; total number of bits is apportioned between the two parts Both components have a sign bit Number of bits used restricts both the magnitude and the precision of the number to be represented; real numbers are always approximations

Representation of Instructions Instruction set: set of operations a particular processor can perform –Specific to each hardware platform –Encoded as binary digits Programming language: language in which a program is written; consists of a set of symbols and the rules for their use

Low-level languages Low-level languages operate at a low level of abstraction: that is, individual symbols have a simple, well-defined, specific meaning Low-level languages operate at or close to the level of the computer’s instruction set; that is, the set of commands a processor is wired to respond to

Low-level languages Specific and simple instructions, non- abstract Platform-specific and non-portable Difficult for humans to read and write Include machine and assembly languages Programs tend to be long, as each instruction is extremely specific

High-level languages High-level languages exist at a higher level of abstraction; individual instructions are often equivalent to several low-level instructions High-level languages are closer to the natural languages humans use to communicate

High-level languages High-level language programs require translation to machine language before they can be executed by a computer As long as you have the software to do the translation, you can run a high-level language program on any kind of computer - thus, high-level languages are said to portable and platform non-specific

High-level languages Because the language is more abstract, a high-level language program tends to be much shorter than its low-level counterpart Most well-known languages are high-level languages - these include C, C++, Java, FORTRAN, BASIC, COBOL, Pascal, python, Ada, etc.

High-level languages Abstract Portable Relatively easy for humans to read and write Include most “named” languages Programs relatively brief Require translation to make executable

Programming Language Translation Interpreters: perform line-by-line translation and execution of a program Compilers: translate entire program into machine language prior to execution Java is unique: uses both methods