Computer Programming I. Today’s Lecture  Components of a computer  Program  Programming language  Binary representation.

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

Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
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.
Three types of computer languages
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
Assembly Language for Intel-Based Computers, 4th Edition
COMP 14 Introduction to Programming
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
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.
CISC1400: Binary Numbers & Computer Fall 2011, Dr. Zhang 1.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
CIS 115 Lecture 1.  Hardware: Electronic Devices  Software: Instructions and Computer Programs.
Why Program? Computer – programmable machine designed to follow instructions Program – instructions in computer memory to make it do something Programmer.
COMPUTER SCIENCE I C++ INTRODUCTION
Technology in Focus: Under the Hood
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
MAC OS – Unit A Page: 10-11, Investigating Data Processing Understanding Memory.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
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.
Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.
Fill in the blanks: (1) _________ has only two possible values 0 and 1. (2) There are __________bits in a byte. (3) 1 kilobyte of memory space can store.
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
What is programming? Steps to solve a problem. Repeatable by executing or “doing” the steps again. UWP - Landgraf Some slides are from Dr. Qi Yang's notes.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 1 February 8, 2005.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
1 MIS 131 Introduction to Algorithms and Programming 2015/2016 Fall - Chapter 1 -
CISC1100: Binary Numbers Fall 2014, Dr. Zhang 1. Numeral System 2  A way for expressing numbers, using symbols in a consistent manner.  " 11 " can be.
1 Programming Fundamentals How to Program in C++ How to Program in C++
COMPUTER PROGRAMMING. Computer programming the objective of the module to gain the necessary skills to develop a computer program using one of the high.
Computer Science Binary. Binary Code Remember the power supply that is inside your computer and how it sends electricity to all of the components? That.
Data Representation, Number Systems and Base Conversions
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
1 Principles of Information Technology Introduction to Software and Information Systems Copyright © Texas Education Agency, All rights reserved.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
CS2301:Computer Programming 2
Technology in Action Chapter 6 Behind the Scenes: A Closer Look at System Hardware.
Data Representation.
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.
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.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming Dr. Halla Abdel Hameed.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
CHAPTER 1 COMPUTER SCIENCE II. HISTORY OF COMPUTERS (1.1) Eniac- one of the worlds first computers Used more electricity than an entire city block of.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
Introduction to Programming AP Computer Science. Computers What is a computer? –CPU –ALU –Memory –Hard Drive.
 Human language : commonly used to express feeling and understand what other people expression.  Computer language : are a languages by which a user.
1.4 Representation of data in computer systems Character.
Computer Architecture and Number Systems
Lec 3: Data Representation
Assembly Language for x86 Processors 6th Edition
3.1 Denary, Binary and Hexadecimal Number Systems
CSCI 198: Lecture 4: Data Representation
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
CSCI 161: Lecture 4: Data Representation
Principles of Information Technology
Computers & Programming Languages
COMS 161 Introduction to Computing
Beyond Base 10: Non-decimal Based Number Systems
Networks & I/O Devices.
Dr. Clincy Professor of CS
Presentation transcript:

Computer Programming I

Today’s Lecture  Components of a computer  Program  Programming language  Binary representation

Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-3 Computer Components  Hardware  CPU  IO device  Main memory  Software  How does computer work?

Computer Components

The Central Processing Unit  “brain” of the computer.

Memory  Random Access Memory (RAM)  Temporary memory  Main memory  Read Only Memory (ROM)  For start-up directions  permanent memory.

The execution speed of a program depends on  CPU  RAM  Why?

Programs  Computer  Hardware  Software  Programs that run on a computer  Operating system  Application software

Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-9 Programming Languages  Three types of programming languages 1. Machine languages  Strings of numbers giving machine specific instructions  Example:

Copyright © 2006 Pearson Addison-Wesley. All rights reserved Programming Languages  Three types of programming languages 2. Assembly languages  English-like abbreviations representing elementary computer operations (translated via assemblers)  Example: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY

Copyright © 2006 Pearson Addison-Wesley. All rights reserved Programming Languages  Three types of programming languages 3. High-level languages  Codes similar to everyday English  Use mathematical notations (translated via compilers)  Example: grossPay = basePay + overTimePay

Copyright © 2006 Pearson Addison-Wesley. All rights reserved Programming Languages (3) Machine Languages Assembly Languages High-Level Languages LOAD A ADD B STORE C C=A+B

Copyright © 2006 Pearson Addison-Wesley. All rights reserved C++  C++ is a third generation language  Why C++ not C  C++ is an object oriented language

Decimal System  Positional base 10 numeral systems  10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9  Use same symbol for different orders of magnitude  For example, “1262” in base 10  1* * * *10 0

Binary  A computer is a “bistable” device  A bistable device:  Easy to design and build  Has 2 states: 0 and 1  One Binary digit (bit) represents 2 possible states (0, 1)

Bits  With 2 bits, 4 states are possible (2 2 = 4) Bit 1 Bit 0 State

Decimal to Binary representation  0: 0  1: 1  2: 10  3: 11  4: 100  5: 101  6: 110  7: 111  8: 1000  9: 1001  10: 1010  11: 1011  12: 1100  13: 1101  14: 1110  15: 1111  16:  17: 10001

Convert Binary to Decimal 18  Interpret binary numbers (transform to base 10)  1101 = 1*2 3 +1*2 2 +0*2 1 +1*2 0 = =13  Translate the following binary number to decimal number 

Convert Decimal to Binary  Procedure: 1. Divide the decimal number by 2 2. Make the remainder the next digit to the left of the answer 3. Replace the decimal number with the quotient 4. If quotient is not zero, Repeat 1-4; otherwise, done

Algorithm  A finite set of well-defined instructions for accomplishing some task which, given an initial state, will terminate in a corresponding recognizable end-state.  Examples:  Select the largest number from a set of number (n)  Suppose n numbers are a1, a2, …an  Set LG=a1;  For i=2 to n, do  if LG<ai, then set LG=ai;  Else do nothing;  The largest number is LG

Convert Decimal number 100 to Binary Number 100 % 2 = 0=> last digit 100 / 2 = % 2 = 0=> 2 nd last digit 50/2 = % 2 = 1=> 3rd last digit 25 / 2 = % 2 = 0=> 4th last digit 12 / 2 = 6 6 % 2 = 0 => 5 th last digit 6 / 2 = 3 3 % 2 = 1 => 6 th last digit 3 / 2 =1 1 % 2 = 1 => 7 th last digit 1 / 2 = 0 The result is

Convert Decimal Number 1492 to Binary Number

Bytes and Words  A group of 8 bits is a byte  A byte can represent 2 8 = 256 possible states  Several bytes grouped together to form a word  Word length of a computer, e.g., 32 bits computer, 64 bits computer

Memory Size Metrics  1KB = 1024 bytes  1MB = 1024 x 1024 bytes  1GB = 1024 x 1024 x 1024 bytes

Representing Text  Text is a series of characters  letters, punctuation marks, digits 0, 1, …9, spaces, return (change a line),…  How many bits do we need to represent a character?  1 bit can be used to represent 2 different things  2 bit … 2*2 = 2 2 different things  n bit 2 n different things  In order to represent 128 different character  Solve 2 n = 128 for n  n=7

ASCII  The American Standard Code for Information Interchange  128 characters  7 bits could be used to represent ASCII characters  However, in 1960s, an 8-bit byte was becoming hardware standard, therefore, it was decided to use 1 byte (8 bits) to store the ASCII code (first 7 bits), with the eighth bit being used as a parity bit to detect transmission errors

ASCII Table