1 Structured Programming in C Welcome to CPSC 206.

Slides:



Advertisements
Similar presentations
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Advertisements

Lecture 1: Overview of Computers & Programming
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Introduction to Computer Systems
1-1 ICS102: Introduction To Computing I King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Ceng 230 Programming with C
Topic 1: Introduction to Computers and Programming
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.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
Computer Systems CS208. Major Components of a Computer System Processor (CPU) Runs program instructions Main Memory Storage for running programs and current.
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510, Section 2.
Chapter Introduction to Computers and Programming 1.
Introduction to Programming Dr Masitah Ghazali Programming Techniques I SCJ1013.
Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI CSCI.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
UNIX Unbounded 5 th Edition Amir Afzal Chapter 1 First Things First.
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
The Computer Systems By : Prabir Nandi Computer Instructor KV Lumding.
CS 1308 Computer Literacy and the Internet Computer Systems Organization.
Lesson 2 — How Does A Computer Process Data?
The Study of Computer Science Chapter 0 Intro to Computer Science CS1510.
Lesson 1b: Computer Systems and Program Development CPS118.
Chapter 5: Computer Systems Organization Invitation to Computer Science, Java Version, Third Edition.
Course ILT Basics of information technology Unit objectives Define “information technology” (IT), distinguish between hardware and software, and identify.
Computers Are Your Future Eleventh Edition Chapter 2: Inside the System Unit Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall1.
The Central Processing Unit: What Goes on Inside the Computer
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
GCSE Information Technology Computer Systems 2 Hardware is the name that is given to any part of a computer that you can actually touch. An individual.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
1 Hardware and Software b Hardware the physical, tangible parts of a computerthe physical, tangible parts of a computer keyboard, monitor, wires, chips,
CPU How It Works. 2 Generic Block Diagram CPU MemoryInputOutput Address Bus Data Bus.
Computer Architecture
Chapter 5 Computing Components. 5-2 Chapter Goals List the components and their function in a von Neumann machine Describe the fetch-decode-execute cycle.
General Concepts of Computer Organization Overview of Microcomputer.
Computer Organization & Assembly Language © by DR. M. Amer.
CSCI-100 Introduction to Computing Hardware Part I.
Computer Hardware A computer is made of internal components Central Processor Unit Internal External and external components.
Beginning Snapshots Chapter 0. C++ An Introduction to Computing, 3rd ed. 2 Objectives Give an overview of computer science Show its breadth Provide context.
CS 1308 Computer Literacy and the Internet. Objectives In this chapter, you will learn about:  The components of a computer system  Putting all the.
The Computer System CS 103: Computers and Application Software.
A.Abhari CPS1251 Topic 1: Introduction to Computers Computer Hardware Computer components Connecting Computers Computer Software Operating System (OS)
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,
The Computer System.
Chapter 2 Turning Data into Something You Can Use
1 Introduction to Computers Prof. Sokol Computer and Information Science Brooklyn College.
 A computer is an electronic device that receives data (input), processes data, stores data, and produces a result (output).  It performs only three.
©2013 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. Introduction to Computers and Computing.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 1: An Overview of Computers and Programming Languages.
ASSEMBLY LANGUAGE PROGRAMMING. Course Objectives Identify the major component of a PC-based system, describe the steps involving in assembling, linking,
1 Chapter 1 Basic Structures Of Computers. Computer : Introduction A computer is an electronic machine,devised for performing calculations and controlling.
Computer Systems Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
Introduction to Programming. Key terms  CPU  I/O Devices  Main memory  Secondary memory  Operating system  User interface  Application  GUI 
Introduction to Computers - Hardware
Computer Architecture and Number Systems
Java Programming: From the Ground Up
Chapter 1: An Overview of Computers and Programming Languages
Chapter 1: An Overview of Computers and Programming Languages
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Introduction of microprocessor
Chapter 1: An Overview of Computers and Programming Languages
C++ Programming: From Problem Analysis to Program Design
Computer Science I CSC 135.
Computer Electronic device Accepts data - input
MARIE: An Introduction to a Simple Computer
Chapter 5: Computer Systems Organization
Introduction to Programming Part 2
ICS103 Programming in C 1: Overview of Computers And Programming
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

1 Structured Programming in C Welcome to CPSC 206

2 Lecture Information

3 Lecture Topics: 0. Introduction to Computer Science 1. Overview of CCh 1, 2 2. Flow of control and functionsCh 3, 4 3. Character processing & fundamental data typesCh 5, 6 4. File I/O Ch Pointers, Arrays, and StringsCh 8, 9, Structures, and linked listsCh 12 Features of C: 7. Enumeration type and storage classesCh 7, 8 8. RecursionCh 11

4 Introduction to Computer Science CONCEPTS AND PROGRAMMING

5 Introduction to Computer Science — Outline  Part I: an overview of computer science.  Part II: computer hardware and software.  Part III: computer languages.

6 Part I: An Overview of Computer Science  What is Computer Science?

7 What is Computer Science? Formal Definition The systematic study of computing systems and computation. The body of knowledge resulting from this discipline contains theories for understanding computing systems and methods; design methodology, algorithms, and tools; methods for the testing of concepts; methods of analysis and verification; and knowledge representation and implementation. Definition provided by the National Coordination Office for Information Technology Research and Development (NCO/IT R&D) Part I: An Overview of Computer Science

8 What is Computer Science? A simple answer The study of how to solve problems with computers. Part I: An Overview of Computer Science What are the specific research areas of computer science?

9 What is Computer Science? 1, Design and Build a computer  Operating Systems  Example of OS: Windows, Unix  CPSC 410 Architecture, Electrical Engineering  ELEN 220, Intro Digital Design  CPSC 321, 462, 469 A computer with user-friendly services 2, Are services provided on the computer so we can use the computer efficiently? Part I: An Overview of Computer Science

10 Windows or Unix What is Computer Science? Computability theory 3, Given a problem, can we use a computer to solve the problem? 4, How to solve it? yes Algorithm Design  CPSC311, Analysis of algorithm Part I: An Overview of Computer ScienceProblem: …………

11 What is Computer Science? Programming Language  CPSC111: Computer Science Concepts and Programming Compilers  CPSC434: Compiler Design 5, Given the algorithm,  How can we translate the algorithm into instructions which computer can understand.  That is, how can we communicate with the computer? Part I: An Overview of Computer Science

12 Windows or Unix What is Computer Science? AlgorithmAlgorithm 3, Given a problem, check whether a computer can solve it. 4, Design an algorithm to solve it. yes Part I: An Overview of Computer Science 1, Design and Build a computer. 2, Friendly services are provided. Problem: ………… 5, Communicate with the computer. Instructions: …………… Architecture Operating System Computability theory Algorithm Design Programming Language, Compiler What else?

13 What is Computer Science? Complexity theory  CPSC311: Analysis of algorithm  CPSC627:Theory of Computability 6, Given a solution for a problem,  Is the solution correct?  Is it efficient?  Is it optimal? Part I: An Overview of Computer Science

14 What is Computer Science? Artificial Intelligence  CPSC320: Artificial Intelligence 7, Given a problem, can the computer finds the solution 8, I have developed a solution for a problem. Human-computer Interaction  CPSC436: Computer- Human Interaction  Is my solution easy for people to use? Part I: An Overview of Computer Science automatically automatically?

15 What is Computer Science? Software Engineering  CPSC 431: Software Engineering 9, I want to develop a BIG software, how can I handle a complicated situation? 10, Internet, Networks, Mobile Ad Hoc Networks ……  How to develop network applications? Networking, Parallel and Distributed Systems.  CPSC 463: Networks and Distributed Processing. Part I: An Overview of Computer Science

16 Summary of Part I Part I: An Overview of Computer Science Architecture Operating System Computability theory Algorithm Design Compiler Complexity theory Artificial Intelligence Human-computer Interaction Software Engineering Parallel and Distributed Systems. Programming Language Networking The study of how to solve problems with computers.

17 Introduction to Computer Science — Outline  Part I: an overview of computer science.  Part II: computer hardware and software.  Part III: computer languages.

18 Part II: Computer Hardware and Software Outline:  The development of modern computer systems.  Computer organization.  Solving problems on computers.  Programming and software engineering.

19 The development of modern computer systems  Early electronic computers  Mainframes  Time sharing  Microcomputers  Networked computing Check course website for details. Part II: Computer Hardware and Software

20 Part II: Computer Hardware and Software Outline:  The development of modern computer systems.  Computer organization.  Solving problems on computers.  Programming and software engineering.

21 Computer Organization Part II: Computer Hardware and Software — Computer Organization

22 O utline Part II: Computer Hardware and Software — Computer Organization CPU Memory Hard Driver Input/Output (1) How data is represented in computer? Secondary Storage

23 Outline Part II: Computer Hardware and Software — Computer Organization  Data representation  Main Memory  Central Processing Unit (CPU)  Secondary Storage  Input / Output

24 Data representation — What is data? Part II: Computer Hardware and Software — Computer Organization The information which a computer processes data values  Individual data values may represent  numbers,  alphabetic characters, or  other coded information.

25 Data representation — What is data?  Instructions of computer programs are also data?  Yes.  The instructions must be stored in the computer’s memory before they are able to be processed. Part II: Computer Hardware and Software — Computer Organization The information which a computer processes

26 Data representation — How data is stored and processed? binary 01 All data is stored and processed in binary form, that is, as a series of 0s and 1s. bit Each binary digit is called a bit  The smallest unit of information which can be stored in the computer. Part II: Computer Hardware and Software — Computer Organization

27 Data representation — How data is stored and processed? A computer word defines the number of bits which can be stored in a memory cell  The length of a word might be different on different computer Bits are grouped into longer units known as bytes to hold more meaningful data. 1 byte = 8 bits Part II: Computer Hardware and Software — Computer Organization

Data representation — Binary Number Counting in decimal Counting in binary Binary Numbers (1*10 3 ) + (9*10 2 ) + (8*10 1 ) + (9*10 0 ) = (1*2 7 ) + (0*2 6 ) + (0*2 5 ) + (1*2 4 ) + (1*2 3 ) + (0*2 2 ) + (0*2 1 ) +(1*2 0 ) = 153 in base One thousand, nine hundred and eighty nine eight times ten Part II: Computer Hardware and Software — Computer Organization

29 Data representation — Binary Number, Examples Part II: Computer Hardware and Software — Computer Organization (1*2 4 ) Try converting these numbers from binary to decimal: = (1*2 1 ) + (0*2 0 ) = 2+0 = 2 =(1*2 2 ) + (1*2 1 ) + (1*2 0 ) = 4+2+1= = = = 30 +(1*2 1 )+(1*2 3 )+ (1*2 2 )+(0*2 0 )

30 Data representation — How data is represented in binary form? Number: +6, - 6, +99  Value of a number Part II: Computer Hardware and Software — Computer Organization  Sign of a number

31 Data representation — How data is processed? Number: sign The sign bit represents the sign of the number. e.g.  0 implies a positive number  1 implies a negative number Part II: Computer Hardware and Software — Computer Organization 6 sign bit magnitude bits In a binary representation, the leftmost bit is a sign bit followed by the magnitude bits.

32 Data representation — How data is processed? Number — Examples: Represented in 16-bit memory, Part II: Computer Hardware and Software — Computer Organization Represented in 8-bit memory,

Data representation — How data is processed? Number — Examples: Part II: Computer Hardware and Software — Computer Organization Represented in 8-bit How to represent +127 in 16-bit memory? 0 sign bit magnitude bits (15 bits) = 0* * * * * * *2 8 +0*2 7 +1*2 6 +1* *2 4 +1*2 3 +1*2 2 +1* *2 0 = 127

34 Data representation — How data is processed? Number — Examples: Represented in 16-bit Part II: Computer Hardware and Software — Computer Organization How to represent in 8-bit memory? Answer: We cannot do it since cannot be represented by a 7-bit binary number. What is the maximum value can be represented by a 7-bit binary number? = 1*2 6 +1* *2 4 +1*2 3 +1*2 2 +1* *2 0 = 127

35 Data representation — How data is processed? Characters: ASCII coding systems ASCII – American Standard Code for Information Interchange Each character is represented in a 7-bit format: Hello  Example: Part II: Computer Hardware and Software — Computer Organization H  E  L  o 

36 Outline Part II: Computer Hardware and Software — Computer Organization  Data representation  Main Memory  Central Processing Unit (CPU)  Secondary Storage  Input / Output

37 Main memory  What is Main memory  It is part of a computer’s electronic circuitry which holds the binary data which the computer’s program will process. Part II: Computer Hardware and Software — Computer Organization

38 Main memory Part II: Computer Hardware and Software — Computer Organization  Memory is divided into cells.  Each cell is assigned a specific address, from 0 to the maximum size of the computer’s memory capacity.

39 Main memory (cont.) size  The size of a computer’s memory is the number of the addressable cells it contains. Bit1 Byte8 bits Kilobyte210 bytes1,000 Megabyte210 kilobyte 1,000,000 Gigabyte210 megabyte 1,000,000,000 Terrabyte210 Gigabytes trillion e.g. A 256K bytes of memory have 256*1024=262,144 bytes. Part II: Computer Hardware and Software — Computer Organization

40 Main memory — Features of Memory  Random Access  High-speed  Read/Write Capability  Volatility  Memory loses its contents when the power is turned off. Part II: Computer Hardware and Software — Computer Organization

41 Outline Part II: Computer Hardware and Software — Computer Organization  Data representation  Main Memory  Central Processing Unit (CPU)  Secondary Storage  Input / Output

42 CPU: Central Processing Unit  CPU is the heart of a computer.  Control unit Control and coordinate the computer’s operations.  Arithmetic/Logic Unit (ALU) performs all arithmetic computations and logic operations. Part II: Computer Hardware and Software — Computer Organization

43 Control unit  Program execution 1. Each computer has a unique instruction set determined by the designers of its architecture. Each instruction includes a code that specifies the operation to be performed, and the memory address of the data value to be acted on. Part II: Computer Hardware and Software — Computer Organization

44 Control unit  Program execution 2. All the operations of a computer are directed by a set of instructions, known as a program, which is loaded in the computer’s main memory during execution. Part II: Computer Hardware and Software — Computer Organization

45 Control unit  Program execution 3. The control unit locates the appropriate instructions, controls their sequencing, and executes them by activating appropriate circuitry. Part II: Computer Hardware and Software — Computer Organization

46 Control unit (cont.)  Program Counter (PC)  contains the memory address of the instruction that is currently being executed.  Instruction counter (IC)  contains the instruction currently being processed. Part II: Computer Hardware and Software — Computer Organization

47 Control unit (cont.)  Hardware characteristics  CPU synchronizes its operations by the regular pulses emitted by an electronic device called a clock.  The speed of a computer can be quoted as:  Clock speed, e.g. 100MHz means 100 million cycles per second.  MIPS, a million instructions per second, or the unit of time it takes to execute one instruction. Part II: Computer Hardware and Software — Computer Organization

48 Arithmetic/Logical Unit  ALU performs all arithmetic computations and logical operations.  Arithmetic - Add, subtract, multiply, divide exponentiation etc.  Logical -Testing for relationships. A<B;name == “mary”; c>=10; possible Answers? True or False Part II: Computer Hardware and Software — Computer Organization The ALU contains special memory cells, known as registers, in which the arithmetic is carried out.

49 reads the individual program instructions from main memory. Executes one instruction at a time until completion Fetch - Decode - Execute The machine cycle algorithm is continuously repeated until program termination. CPU Machine Cycle Part II: Computer Hardware and Software — Computer Organization

50 Fetch:  Retrieve the next instruction from memory [where the command is located (address) in program counter]  Update the program counter to the address of the next instruction.  The instruction just Fetched is placed in register. Part II: Computer Hardware and Software — Computer Organization

51 Decode the Bit pattern in the register Having decoded the instruction, the control unit enters the execute phase. It activates the correct circuitry to perform the requested task. Decode: Execute: Part II: Computer Hardware and Software — Computer Organization

52  If the instruction is a load from memory, the Control Unit causes the load to occur.  If the instruction is for an arithmetic operation, the control unit activates the appropriate circuitry in the ALU with the correct input stored in registers.  When the instruction has been executed, the control unit again begins the machine cycle with the Fetch cmd (the address of the next cmd is in the program counter). Part II: Computer Hardware and Software — Computer Organization

53 Secondary Storage Mass storage devices Sequential storage: tape. Random storage: floppy disk, zip disk, CD- ROM, etc. Indirect addressing. Static storage. Slower speed. Part II: Computer Hardware and Software — Computer Organization

54 User Input / Output  Input  Devices: keyboard, mouse, light pen, etc.  Data translation: interfaces.  Output  Devices: computer screen, printer (dot matrix, ink jet or laser), etc.  Data translation: buffers. Part II: Computer Hardware and Software — Computer Organization

55 IPOS Cycle I - Input Part II: Computer Hardware and Software — Computer Organization Data/ Program Memory P - Process CPU Program Output O - OutputS - S econdary Storage Medium Data/Program