Page 5 - Computer Programming
P. 5


        Q   Compare and contrast computer            4  Chapter 1    Computer Programming and the Workplace
           storage capacity. Think of each
                                                                    Bits and Bytes
           capacity as the following: a byte as a                   Before we discuss memory, let’s look at how information (data and programs) are
           single character, a kilobyte as a short                  stored in a computer.
                                                                     A computer is really nothing more than a series of switches. Each switch exists
           paragraph, a megabyte as a short                         in two states: on or off. Storing information in a computer is simply a matter of
                                                                    setting a sequence of switches on or off. If the switch is on, its value is 1. If the
           novel, or a high-resolution photo-                       switch is off, its value is 0. These 0s and 1s are interpreted as digits in the binary
           graph, a gigabyte as 7 minutes of an      bits           number system and are called bits (binary digits).
                                                     byte            The minimum storage unit in a computer is a byte. A byte is composed of eight
           HD video, and a terabyte as 50,000                       bits. A small number such as 3 can be stored as a single byte. To store a number
                                                                    that cannot fit into a single byte, the computer uses several bytes.
           trees made into paper and printed.                        Data of various kinds, such as numbers and characters, are encoded as a series
           Have students draw pictures in their                     of bytes. As a programmer, you don’t need to worry about the encoding and
                                                                    decoding of data, which the computer system performs automatically, based on
           notebook to help recall a computer’s      encoding scheme  the encoding scheme. An encoding scheme is a set of rules that govern how a com-
                                                                    puter translates characters, numbers, and symbols into data the computer can
           storage capacity.
                                                                    actually work with. Most schemes translate each character into a predetermined
                                                                    string of bits. In the popular ASCII encoding scheme, for example, the character
        Q   Model the visual representation                         C is represented as 01000011 in one byte.
                                                                     A computer’s storage capacity is measured in bytes and multiples of the byte,
           of memory locations. Use an egg                          as follows:
           carton with plastic Easter eggs to        kilobyte (KB)     Q     A kilobyte (KB) is about 1,000 bytes.
           demonstrate data in addressed             megabyte (MB)     Q     A megabyte (MB) is about 1 million bytes.
           memory locations.                         gigabyte (GB)     Q     A gigabyte (GB) is about 1 billion bytes.
                                                     terabyte (TB)     Q     A terabyte (TB) is about 1 trillion bytes.
                                                                     A typical one-page word document might take 20 KB. Therefore, 1 MB can
                                                                    store 50 pages of documents and 1 GB can store 50,000 pages of documents. A
                                                                    typical two-hour high- resolution movie might take 8 GB, so it would require 160
                                                                    GB to store 20 movies.
                                                     memory         A computer’s memory consists of an ordered sequence of bytes for storing pro-
                                                                    grams as well as data that the program is working with. You can think of memory
                                                                    as the computer’s work area for executing a program. A program and its data must
                                                                    be moved into the computer’s memory before they can be executed by the CPU.
                                                     unique address  Every byte in the memory has a unique address, as shown in Figure 1.2. The
                                                                    address is used to locate the byte for storing and retrieving the data. Since the
                                                                    bytes in the memory can be accessed in any order, the memory is also referred to
                                                     RAM            as random-access memory (RAM).
                                                                     Generally speaking, the more RAM a computer has, the faster it can operate,
                                                                    but there are limits to this simple rule of thumb.
                                                                     A memory byte is never empty, but its initial content may be meaningless to
                                                                    your program. The current content of a memory byte is lost whenever new infor-
                                                                    mation is placed in it.

        4   CHAPTER 1     Q   Computer Programming and the Workplace
   1   2   3   4   5