Introduction to Computer Programming

Slides:



Advertisements
Similar presentations
Hardware Lesson 3 Inside your computer.
Advertisements

 2002 Prentice Hall Hardware Basics: Inside The Box Chapter 2.
FIRST COURSE Essential Computer Concepts. New Perspectives on Microsoft Office 2007: Windows XP Edition 2 Objectives Compare the types of computers Describe.
Computer Hardware Introduction. Computer System Components Input Keyboard, Mouse, Camera, Touch Pad Processing CPU Output Monitor, Printer Storage Floppy,
Chapter 2: Hardware Basics Section I: Preparing to Use Technology.
Essential Computer Concepts. XP New Perspectives on Microsoft Office 2007: Windows XP Edition2 What Is a Computer? A computer is an electronic device.
How Computers Work. A computer is a machine f or the storage and processing of information. Computers consist of hardware (what you can touch) and software.
Aug CMSC 104, LECT-021 Machine Architecture and Number Systems Some material in this presentation is borrowed form Adrian Ilie From The UNIVERSITY.
An Introduction to Hardware, Software, and the Internet
EMT1111 Logic and Problem Solving Lecture 2 Dr. Benito Mendoza.
CSCI 125 & 161 Lecture 2 Martin van Bommel. Hardware vs Software Hardware - physical components you can see and touch –e.g. processor, keyboard, disk.
Computer Systems. Basic Components Auxiliary Storage OutputProcessor Main Memory Input.
CPU (CENTRAL PROCESSING UNIT): processor chip (computer’s brain) found on the motherboard.
1 Machine Architecture and Number Systems Topics Major Computer Components Bits, Bytes, and Words The Decimal Number System The Binary Number System Converting.
Configuration.
Chapter Two Hardware Basics: Inside the Box. ©1999 Addison Wesley Longman2.2 Chapter Outline What Computers Do A Bit About Bits The Computer’s Core: CPU.
MAC OS – Unit A Page: 10-11, Investigating Data Processing Understanding Memory.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
1 Introduction to Computers Prof. Sokol Computer and Information Science Brooklyn College.
Copyright © 2003 by Prentice Hall Module 5 Central Processing Unit 1. Binary representation of data 2. The components of the CPU 3. CPU and Instruction.
Hardware Data Storage.
Computer Parts. Two Basic Parts Hardware & Software.
Machine Architecture CMSC 104, Section 4 Richard Chang 1.
The Four Parts of a Computer. Definition of a Computer A computer is an electronic device used to process data, converting the data into information that.
What is a computer? A computer is a device that:
Introduction to Computer Systems and the Java Programming Language.
Computer Confluence 7/e © 2006 Prentice-Hall, Inc.
IT Groundwork ICS3UC - Unit 1 Hardware. Overview of Computer System.
Lesson 3 — How a Computer Processes Data Unit 1 — Computer Basics.
School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic.
Introduction to Programming Instructor: Yong Tang Brookhaven National Laboratory Working on accelerator control (BNL Phone #)
CSCI-100 Introduction to Computing Hardware Part I.
The Computer System CS 103: Computers and Application Software.
General Computer Knowledge COE 201- Computer Proficiency.
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 Two Hardware Basics: Inside the Box ©1999 Addison Wesley Longman2.2 Chapter Outline What Computers Do A Bit About Bits The Computer’s Core: CPU.
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.
COMPUTER SYSTEM A computer system is define as combination of components designed to process data and store files. A computer system consists of four.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Introduction To Computer Programming – 1A Computer Parts, Words, and Definition Herriman High School.
Introduction to Programming. Key terms  CPU  I/O Devices  Main memory  Secondary memory  Operating system  User interface  Application  GUI 
Basic Computer Components Unit 2. What is a computer?  A computer is an electronic device that accepts raw data and processes it into information that.
Information Technology (IT). Information Technology – technology used to create, store, exchange, and use information in its various forms (business data,
Computer Graphics HARDWARE. Computers  Computers are automatic, electronic machines that –accept data & instructions from a user (INPUT) –store the data.
ICT COMPUTER FUNDAMENTALS
Basic Computer Fundamentals
Computer Architecture and Number Systems
An Overview of the Computer System
UNIT 9 Computer architecture
Chapter 1: An Overview of Computers and Programming Languages
Storage Hardware This icon indicates the slide contains activities created in Flash. These activities are not editable. For more detailed instructions,
Principles of Information Technology
ICT COMPUTER FUNDAMENTALS
TexPREP Summer Camp Computer Science
Computer Hardware Introduction.
Introduction to Computers
Chapter Three Computer Hardware Chapter 3- Computer Hardware.
Introduction to Computers
Looking Inside the machine (Types of hardware, CPU, Memory)
An Overview of the Computer System
How do computers work? Storage.
Computer Electronic device Accepts data - input
المحور 3 : العمليات الأساسية والمفاهيم
Chapter Three Computer Hardware Chapter 3- Computer Hardware.
Programming Languages
Computer Electronic device Accepts data - input
Introduction to Computers
Chapter 2: Computer Hardware
Computer Electronic device Accepts data - input
Presentation transcript:

Introduction to Computer Programming 1 Introduction to Computer Programming

Overview What is a computer? Components Units of storage Encoding Hardware Software Units of storage Encoding

What is a computer? A computer is a collection of electrical and mechanical devices that can accept input and provide output via input and output devices respectively Processes data (input) to produce a result (output) Very fast execution of simple instructions Simple; example logic true and false, loops Combination of simple instructions generate more complex ones

Figure of a motherboard Components Figure of a motherboard Hardware Internal devices Motherboard Interconnect internal devices Power supply Central Processing Unit (CPU) Speed in Hertz (Hz, cycles per second) Normally it is used the clock speed, in the order of GHz (1,000,000,000 Hz) CPU FDD: Floppy Disk Drive The CPU(s) needs to be close to motherboard to reduce distance to other devices like RAM that means bigger faster (quicker access) and less power consumption (heat produced – less important given the lengths considered)

Components Hardware Internal devices (cont.) Memory Volatile memory Random Access Memory (RAM) Persistent memory Read Only Memory (ROM) Hard drive Data storage device (read/write) RAM Hard drive FDD: Floppy Disk Drive The CPU(s) needs to be close to motherboard to reduce distance to other devices like RAM that means bigger faster (quicker access) and less power consumption (heat produced – less important given the lengths considered)

Components CPU Power and data cables Power supply Ventilation Memory Speaker Ventilation Memory Hard drive RAM Power supply Motherboard

Components Hardware (cont.) External also called peripherals Input; provides data to the computer Keyboard Mouse Touch screen ... Output; gets data from the computer Monitor Printer Scanner External Storage Device Speakers Exercise: What other device is input and output? Touch screen and external memory device (e.g. USB stick, external mass storage device) are both input and output devices.

Components Software Basic Input/Output System (BIOS) Instructions and setup for how a system should boot and how it operates Operating System (OS) Consists of programs that manage the computer hardware and resources, and provides common services for efficient execution of applications Programs Are a sequence of instructions written to perform a specified task Mainly the BIOS the following functions: POST – Tests the computer hardware, ensuring hardware is properly functioning before starting process of loading the operating system. Bootstrap Loader - Processes the location of the Operating System. If Operating System located, BIOS will pass the control to it. BIOS - Software / Drivers that interface between the operating system and your hardware. BIOS / CMOS Setup - It’s a configuration program that allows to configure hardware settings including system settings such as computer passwords, time, and date. BIOS and OS in machine language (has been compiled) to make them faster and more efficient. Programs may not like in the case of Java, we’ll see more in future lectures.

Units of storage Units of storage Bit Bytes Kilobytes (KB) Two valid values 0 or 1 Bytes 8 bits Represents numbers from -128 to 127 (or 0 to 255) Kilobytes (KB) 1KB is 1024 Bytes Megabytes (MB) 1MB is 1024 KB Gigabytes (GB) 1GB is 1024 MB Terabytes (TB) 1TB is 1024 GB Machines represent integers with 4 Bytes (32 bits) or 8 Bytes (64 bits) 4 Bytes maximum integer represented is –2147483648 to 2147483647 (normally used highest bit to represent the sign)

Encoding Encoding is the way a number may be represented In the case of integers Decimal Ten values are used in the representation Uses 0, 1, ..., 9 to represent the number Binary Two values are used in the representation Uses 0 and 1 to represent the number Hexadecimal Sixteen values are used in the representation Uses 0, 1, ..., 9, a, b, ..., f to represent the number There are more representations, as octal, but the most used are decimal, binary and hexadecimal. 0 to 9 normally called digits

Encoding Binary 16 + 1 17 = Decimal Binary Byte Decimal Binary (base 2) Bit Bit value 1 16 1 1 8 + 1 17 16 1 16 1 128 1 32 1 2 1 64 1 4 128 64 32 16 8 4 2 1 8 Bit index 7 6 5 4 3 2 1 20 21 22 27 23 26 25 24 Bit exponential representation /** * Builds the binary representation of the provided number. * * @param iValue the number to represent in binary. * @return the binary representation of the provided number. */ public static String toBin(final int iValue) { final String alpha = "01"; // representing values final int iRemainder = (iValue % 2); // amount left over String strBin; if (iValue == iRemainder) { // Last element in the representation strBin = alpha.charAt(iRemainde); } else { // Build next element in the representation strBin = toHex(iValue / 2) + alpha.charAt(iRemainder); } return strBin; } // toBin() 17 = 00000000  0 ... 01111111  127 ... 11111111  255

Encoding Hexadecimal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 a b c d e f Dec Hex Divide by 16 Hexadecimal (base 16) 17 16 1 16 1 Byte 1 1 1 Divide by 16 255 5 16 16 1 5 255 Dec f ff Hex 9 One Byte is represented by two hexadecimal values, example ff for 255 or 7f for 127. Red Green Blue (RGB) colour representation, where each colour is represented in a byte in hexadecimal; white ffffff, red ff0000, green 00ff00 and blue 0000ff. The other values refers to mix of the tree main colours, red green and blue. /** * Builds the hexadecimal representation of the provided number. * * @param iValue the number to represent in hexadecimal. * @return the hexadecimal representation of the provided number. */ public static String toHex(final int iValue) { final String alpha = "0123456789ABCDEF"; // representing values final int iRemainder = (iValue % 16); // amount left over String strHex; if (iValue == iRemainder) { strHex = alpha.charAt(iRemainde); } else { strHex = toHex(iValue / 16) + alpha.charAt(iRemainder); } return strHex; } // toHex() 80 15 f f f 15

Encoding Examples Colour representation Red Green Blue (RGB) Purple Three bytes one for each colour Purple D5F1C9 Examples 213 49 201 Black 000000 Absence of any colour Red FF0000 Just RED colour Green 00FF00 Just GREEN colour Blue 0000FF Just BLUE colour White FFFFFF WHITE colour Purple: 213-49-201

Encoding Examples (cont.) American Standard Code for Information Interchange (ASCII) Encoding of characters and some symbols Just English alphabet Extended ASCII provides some extra Latin characters, for example Spanish ñ character Unicode Character Representations To support other languages it is required 2 bytes - called internationalisation Java uses Unicode Character Representation (16 bits representation)

Encoding ASCII DEC HEX BIN Symbol ... 53 35 00110101 5 74 4A 01001010 J 95 5F 01011111 _ 33 21 00100001 ! 54 36 00110110 6 75 4B 01001011 K 96 60 01100000 ` 34 22 00100010 " 55 37 00110111 7 76 4C 01001100 L 97 61 01100001 a 23 00100011 # 56 38 00111000 8 77 4D 01001101 M 98 62 01100010 b 24 00100100 $ 57 39 00111001 9 78 4E 01001110 N 99 63 01100011 c 25 00100101 % 58 3A 00111010 : 79 4F 01001111 O 100 64 01100100 d 26 00100110 & 59 3B 00111011 ; 80 50 01010000 P 101 65 01100101 e 27 00100111 ' 3C 00111100 < 81 51 01010001 Q 102 66 01100110 f 40 28 00101000 ( 3D 00111101 = 82 52 01010010 R 103 67 01100111 g 41 29 00101001 ) 3E 00111110 > 83 01010011 S 104 68 01101000 h 42 2A 00101010 * 3F 00111111 ? 84 01010100 T 105 69 01101001 i 43 2B 00101011 + 01000000 @ 85 01010101 U 106 6A 01101010 j 44 2C 00101100 , 01000001 A 86 01010110 V 107 6B 01101011 k 45 2D 00101101 - 01000010 B 87 01010111 W 108 6C 01101100 l 46 2E 00101110 . 01000011 C 88 01011000 X 109 6D 01101101 m 47 2F 00101111 / 01000100 D 89 01011001 Y 110 6E 01101110 n 48 30 00110000 01000101 E 90 5A 01011010 Z 111 6F 01101111 o 49 31 00110001 1 70 01000110 F 91 5B 01011011 [ 112 01110000 p 32 00110010 2 71 01000111 G 92 5C 01011100 \ 113 01110001 q 00110011 3 72 01001000 H 93 5D 01011101 ] 114 01110010 r 00110100 4 73 01001001 I 94 5E 01011110 ^ 97 61 01000010 a 65 41 01000010 A A byte represent a character in ASCII but just in English alphabet, the extended ASCII cover other characters like Latin (Spanish). Need to use 2 bytes to be able to represent all languages in the world. Java has build-in support for internalisation. /** * Builds the binary representation of the provided number. * * @param iValue the number to represent in binary. * @param iBase the base of the encoding, form 2 (binary) to 16 (hexadecimal). * @return the binary representation of the provided number. * @throws IllegalArgumentException when an invalid encoding base is provided. */ public static String toEncode(final int iValue, final int iBase) { if (iBase < 2 || iBase > 16) { // Runtime exception so does't need to be specified in the method declaration throw new IllegalArgumentException("Invalid encoding base of " + iBase + " that should be bigger or equal to 2 and smaller or equal" + " to 16"); } final String alpha = "0123456789ABCDEF"; // representing values final int iRemainder = (iValue % iBase); // amount left over String strRepresentation; if (iValue == iRemainder) { // Last element in the representation strRepresentation = alpha.charAt(iRemainde); } else { // Build next element in the representation strRepresentation = toHex((iValue/iBase), iBase) + alpha.charAt(iRemainder); return strRepresentation; } // toEncode()