1 / 31

CHAPTER 1: Introduction to Computers and Programming

CHAPTER 1: Introduction to Computers and Programming. CSEB113 PRINCIPLES of PROGRAMMING CSEB134 PROGRAMMING I by Badariah Solemon. Topics. Overview of PC components Programming languages C programming language C programming environment C program at a glance. Topic 1.

pkirkwood
Download Presentation

CHAPTER 1: Introduction to Computers and Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHAPTER 1: Introduction to Computers and Programming CSEB113 PRINCIPLES of PROGRAMMING CSEB134 PROGRAMMING I by Badariah Solemon BS (May 2012)

  2. Topics • Overview of PC components • Programming languages • C programming language • C programming environment • C program at a glance BS (May 2012)

  3. Topic 1 Overview of PC components BS (May 2012)

  4. Hardware Elements of a Computer 3 2 1 4 5 2 1 Software Program? BS (May 2012)

  5. Main Memory • A semiconductor device which stores the information necessary for a program to run. • Types: • ROM (Read Only Memory) • Contains information that is necessary for the computer to boot up • The information stays there permanently even when the computer is turned off. • RAM (Random Access Memory) • Contains instruction or data needed for a program to run • Got erased when the computer is turned off. BS (May 2012)

  6. Anatomy of Main Memory • Memory may be conceptually viewed as an ordered sequence of storage location called memory cells. • Information is stored in memory in bits • A memory cell is a group of bits called a byte • Each memory cell has a unique address 01110110 10010101 B2 A2 10010001 00010110 B4 A4 10000110 10010110 B1 A1 10010000 11010000 B6 A6 10101110 11010110 B3 A3 10110111 10110010 B8 A8 00001010 10010111 B5 A5 11011100 01110111 B7 A7 01111110 10001100 B9 A9 Ref: Tan and D’Orazio, C Programming for Engineering & Computer Science, New York: McGraw-Hill BS (May 2012)

  7. CPU • Does most of the work in executing a program • The CPU inside a PC is usually the microprocessor • Three main parts: • Control Unit • Fetch instructions from main memory and put them in the instruction register • ALU (Arithmetic Logic Unit) • Execute arithmetic operations • Registers • Temporarily store instructions or data fetched from memory BS (May 2012)

  8. Secondary Storage Devices • Magnetic devices used to store a large amount of information. • Store the software components or data needed for the computer to execute its tasks. • Could be “read only” or “writable”. • Example: BS (May 2012)

  9. Input/Output Devices • Input Devices • Accepts information from the user and transforms it to digital codes that the computer can process • Example: • Output Devices • An interface by which the computer conveys the output to the user • Example: BS (May 2012)

  10. Computer Networks • Computers are now linked together in networks – communicate • Types: • LAN ( ) • Computers and other devices in a building are connected by cables or wireless network • WAN ( ) • Links many individual computers and LANs over a large geographic area • The most well-known WAN is _____________ BS (May 2012)

  11. Software • Consists of programs that enable us to solve problems with a computer Operating Systems Utility Programs Language Translation System Software Application Software *Complete this list BS (May 2012)

  12. Topic 2 programming languages BS (May 2012)

  13. What is Programming? • Programmingis instructing a computer to do something for you with the help of a programming language • A programming language contains instructionsfor the computer to perform a specific action or a specific task: • 'Calculate the sum of the numbers from 1 to 10‘ • 'Print “I like programming”‘ • 'Output the current time' BS (May 2012)

  14. What is Programming? • Programming Language is different compared to our everyday-language (natural language); spoken and written • Does not have to be 100% but still understandable • Depends on circumstances; the context – one word can have many meaning depending on the situation • For example: • OPERATE BS (May 2012)

  15. What is Programming? • The two roles of a programming language: • Technical: It instructs the computer to perform tasks. • Conceptual: It is a framework within which we organize our ideas about things and processes. • In programming, we deal with two kind of things: • Data - representing 'objects' we want to manipulate • Procedures-'descriptions' or 'rules' that define how to manipulate data BS (May 2012)

  16. Programming Language • Programming Language is a Formal Language used to communicate to a computer. • Very specific (one word means one thing – context free) since to 'talk' to a computer; to instruct a computer; our commands must be 100% clear and correct. • Either Functional - tell what to do but not how (sum [1...10]) • or Imperative - describing the step by step to accomplish the task (Take the first number and add the next number to it; then add the next number to the sum; and …………; until you have reached 10 as number to be added. Then print the sum of all numbers) BS (May 2012)

  17. Programming Language • Can be classified into as a special-purpose and general-purpose programming languages. • Special-purpose : is design for a particular type of application • Structured Query Language (SQL) • General-purpose : can be used to obtain solutions for many types of problems • Machine Languages • Assembly Languages • High-Level Languages BS (May 2012)

  18. 1. Machine Language • The only language that the processor actually understand. • Consists of binary codes: 0 and 1 • Example: 1101 0001 1000 0101 1000 0110 1111 0001 0100 1100 0101 1110 0101 1010 0001 1100 • Each of the lines above corresponds to a specific task to be done by the processor. • Programming in machine code is difficult and slow since it is difficult to memorize all the instructions. Mistakes can happen very easily. • Processor dependent (different machine language for different CPU) - not portable BS (May 2012)

  19. 2. Assembly Language • Enable machine code to be represented in words and numbers. • Example of a program in assembly language: LOAD A, 9999 LOAD B, 8282 • Cannot be processed directly by a computer, must be converted to machine language using assemblers • Easier to understand compared to machine code but still is quite difficult to use. • Each instruction corresponds to a specific machine code: lengthy programs. • Processor dependent and not portable. LOAD A, 9999 LOAD B, 8282 SUB B MOV C, A LOAD A, 9999 LOAD B, 8282 SUB B MOV C, A 0111001100 1000110011 1001111001 1100110010 Assembler BS (May 2012)

  20. 3. High-level Language • Use more English words. They try to resemble English sentences so easier to program in these languages. Example: printf (“Hello”) • The programming structure is problem oriented - does not need to know how the computer actually executesthe instructions. • Processor independent- the same code can be run on different processors. • Needs to be analyzed by the compilerand then compiled into machine code so that it can be executedby the processor. • Example languages – Java, BASIC, C, C++ BS (May 2012)

  21. Topic 3 C Programming language BS (May 2012)

  22. What is ‘C’? • Why ‘C’? - Because based on 'B'; developed at Bell Laboratories • C was developed by Dennis Ritchie at Bell Laboratories in 1972. • C combines the power of high-level languages with the power of assembly languages. • Starts as a system implementation language, but has evolved into general-purpose language and available for a wide variety of computers. • C coupled with good program design techniques - generate well structured, easy to read and easy to maintain program BS (May 2012)

  23. What is ‘C’? • In 1983, the American National Standards Institute (ANSI) set up X3J11, a Technical Committee to draft a proposal for the ANSI standard, which was approved in 1989 and referred to as the ANSI/ISO 9899 : 1990 or simply the ANSI C, which is now the global standard for C. BS (May 2012)

  24. C – An Imperative Language • C is a highly imperative language • We must tell it exactly how to do what; • the means and functions to use; • which librariesto use; • when to add a new line; • when an instruction is finished; • in short: everything and anything… • Hint: Observe the syntaxin the next slide • Semantics – the meaning of the language within a given context • Syntax - Syntax are the rules to join words together in forming a correct expressionor phrase. BS (May 2012)

  25. Example of a C program function for printing a character/string BS (May 2012) *Complete the labeling

  26. Topic 4 C Programming Environment BS (May 2012)

  27. IDE • The system software necessary to develop C application program are bundled into an integrated development environment (IDE) • A typical IDE contains text editor, C compiler, preprocessor, libraries, other tools • Components of C programming environment: • Language – features to carry out basic operations (Ex. Compare data values, arithmetic operation) • Libraries – routines to carry out operations not part of the language (Standard libraries – ex. #include <stdio.h>& programmer-defined libraries) BS (May 2012)

  28. Ms Visual C++ BS (May 2012)

  29. Topic 5 C program at a glance BS (May 2012)

  30. A Simple C Program Output: CONSOLE VIEW of the C program’s output BS (May 2012)

  31. Summary • PC components • Hardware : main memory, CPU, storage devices, I/O devices • Software : system software & application software • Programming languages • Machine language, assembly language, high-level languages • C as a highly imperative language • A typical C programming environment contains text editor, C compiler, preprocessor, libraries, other tools BS (May 2012)

More Related