Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Programming

Similar presentations


Presentation on theme: "Introduction to Programming"— Presentation transcript:

1 Introduction to Programming
Instructor: Sanchita Mal-Sarkar Course: CIS 260

2 Computer An electronic machine that accepts input, processes data, stores data, and produces output. Data can be numbers, text, images, graphics, and sound, etc. Computer program is a set of instructions. Without it computer is useless. Programming languages allow us to write these instructions (e.g. C, C++, Java, etc).

3 Computer system A computer system consists of a computer, peripheral devices, and software. The computer itself can take care of the processing function, but it needs additional components, called peripherals, to accomplish its input, output and storage functions. Example of an internal peripheral device is hard disk drive.

4 Computer Hardware Hardware is the physical component of a computer.
Hardware is the equipment used to perform the necessary computations. Examples: Main memory (RAM, ROM), secondary memory (hard disk drive, floppy disk drive), CPU, input devices (keyboard and mouse), and output devices (monitor and printer).

5 Hardware Components of a Computer System
Central Processing Unit (CPU) Arithmetic-Logic Unit Control Unit Input Devices Secondary Storage Magnetic disk Optical disk Magnetic tape Keyboard Computer mouse Touch screen Source data automation Buses Output Devices Printers Video display terminals Plotters Audio output Communications Devices Primary Storage

6 Central Processing Unit (CPU)
Coordinating all computer operations. Performs arithmetic and logical operations on data. To process a program stored in main memory, - CPU retrieves each instruction in sequence. - Interprets the instruction to determine what should be done. - Retrieves any data needed to carry out that instruction - Then CPU performs the actual manipulation. CPU’s current instruction and data values are stored temporarily inside the CPU in special high-speed memory locations called registers.

7 Central Processing Unit (CPU)
The CPU consists of a control unit and an arithmetic-logic unit. Three kind of buses link the CPU, primary storage, and other devices in the computer systems. The data bus moves data to and from primary storage. The address bus transmits signals for locating a given address in primary storage. The control bus transmits signals specifying whether to read or write data to or from a given primary storage address, input device, or output device.

8 Data Bus, Address Bus, and Control Bus
Central Processing Unit (CPU) Primary Storage 1 T U # 8 Arithmetic-Logic Unit = 36 12 < 24 Control Unit Data Bus Address Bus Control Bus Output Devices Secondary Storage Input Devices

9 Main Memory Computer memory is a set of storage locations on the main circuit board (motherboard). Four types of memory: RAM, virtual memory, ROM, and CMOS (complementary metal oxide semiconductor memory)

10 Random access memory Consists of electronic circuits on the motherboard (main circuit board). Temporarily hold programs and data while the computer is on. Each circuit has address that is used by the microprocessor to transmit and store data. RAM is constantly changing (volatile). E.g. When we write a paper, the word processing program will be temporarily copied into RAM so that microprocessor can quickly access the required instructions.

11 Virtual Memory Today’s microcomputer software uses space on computer’s storage devices to simulate RAM if more needed. This extra memory is called virtual memory. How it works? Suppose my computer is running a word processing program that takes up most of the memory in RAM, but I want to run a spreadsheet program at the same time.

12 Virtual Memory (Cont.) The OS moves the infrequently used segment of the word processing program into virtual memory on disk. The spreadsheet program now can be loaded into RAM. If that segment is later needed, it is copied from virtual memory back to RAM. Disadvantage:It is much slower than RAM.

13 Read-only memory(ROM)
Another set of electronic circuits on the motherboard inside the computer. We cannot increase ROM capacity. Manufacturer permanently installs ROM. When computer is on, the sets of instructions in ROM checks all the computer system’s components to make sure they are working and activates the essential software that controls the processing function.

14 Complementary metal oxide semiconductor(CMOS)
A chip installed on the motherboard. Activated during the boot process. Contains information about where the essential software is stored. A small rechargeable battery powers CMOS. It changes every time we add or remove hardware to the computer system. CMOS is referred as semipermanent memory.

15 Secondary Storage Devices
RAM retains data only when the power is on, so computer must have a more permanent storage option. The most common magnetic storage devices are hard disk drive, floppy disk drives, and tape drives.

16 Hard disk drive most computers contains one hard disk that cannot be removed from drive. Provides a storage area to be shared by all users of the computer. Generally, the programs that are needed to operate the computer system are stored here. Advantages over floppy disk: speed and capacity.

17 Hard Disk Drive Internal Components

18 Floppy disk drive Most common magnetic storage device.
Users can have any number of floppy disks that can be inserted into computer’s floppy disk drive. High density disk- capacity to store 1.44 MB. Low-density disk - capacity to store 720 KB.

19 Tape drive Another magnetic storage device.
Provides inexpensive archival storage for large quantities of data. Too slow to be used for day-to-day tasks. Used to make backup copies of data stored on hard disks. If a hard disk fails, data from the backup tape can be reloaded on a new hard disk.

20 Compact Disk Read Only Memory (CD-ROM)
Optical storage device. Uses laser technology to read and write data on compact discs (CDs). High capacity and portability. Can store up to 680 MB, equivalent to more than 450 floppy disks. Disadvantage: The surface of the CD is not rewriteable like magnetic media. Once the laser cuts a pit in its surface, the pit cannot be recut, so the data stored there cannot be changed. Relatively slow access. Mainly used for software distribution and storing large data files such as graphics, animation, and video.

21 Input Devices Input device - keyboard, mouse.
When we press a letter or digit key on a key board, that character is sent to main memory and displayed on the monitor. Keyboard consists of three major parts: main keyboard, keypads, and function keys. A mouse is a hand-held device used to select an operation.

22 Output Devices Shows the result of processing data.
Output devices - monitor and printer. Monitor is the TV-like device that displays the output from a computer. Printer produces a hard copy of the text or graphics processed by the computer.

23 Processing Hardware The most important computer function is processing data. To understand this you need to learn how the computer represents and stores data. Computer does not understand human language because it is an electronic device that interpret every signal as either “on” or “off” like a light bulb.

24 Binary Representation of Data
For information to flow through a computer system, it must be in form suitable for processing. All symbols, pictures, or words must be reduced to a string of binary digits. A binary digit is called a bit and it represents either a 0 or a 1. In the computer, the presence of an electronic or magnetic signal means “one” and its absence means “zero”. A string of 8 bits that computer stores as a unit is called a byte. Each byte is used to store a decimal number, a symbol, a character, or a part of a picture. By using binary number system a computer can express all numbers as group of zeroes and ones. There are two standard binary codes: EBCDIC (Extended Binary Coded Decimal Interchange Code) ASCII (American Standard Code for Information Interchange).

25 Bits and Bytes 1 or One bit 1 1 One byte for character A
1 or One bit 1 1 One byte for character A The Computer representation in ASCII for the name ALICE is: 1 A 1 1 1 L 1 I 1 1 1 C 1 1 1 E

26 Data representation Computer represents “on” with a 1 and “off” with a 0. These numbers are called binary digits or bits. Binary number system: most widely used method for interpreting bit settings as nonnegative integers. 38 (decimal) = =

27 Ones complement notation
One of the widely used methods for representing negative binary numbers. A negative number is represented by changing each bit to the opposite bit setting. Example: 38 (decimal) = (binary) -38 (decimal) = (binary)

28 Twos complement notation
Another popular method of representing negative binary number In this method, 1 is added to the ones complement representation of a negative number. Example: -38 (decimal) = (ones complement) -38 (decimal) = (twos complement)

29 Floating-point notation
Usual method to represent real numbers Real number is represented by a number, called a mantissa, times a base raised to an integer power, called an exponent. Example: = x 10 -2 Other possibilities x 10 3, x100 (we choose mantissa is an integer with no tailing 0s)

30 Floating-point notation(cont.)
A real number is represented by a 32-bit string. 24-bit for mantissa and 8-bit for exponent. Base is fixed to 10. Example 100 = = = 24-bit binary representation of is 8-bit twos complement binary representation of -2 is

31 Data Communications Channel => The message needs some kind of medium to be transmitted. This medium is called channel. For example, telephone or coaxial cable, microwave signal, or optical fibers Protocol => The rules that establish an orderly transfer of data between the sender and the receiver are called protocols. Computer software and hardware establish these protocols at the beginning of the transmission, and both computers have to follow the protocols to ensure accurate transfer of data.

32 Data Communications The transmission of text, numeric, voice, or video data from one machine to another is called data communications. For example, Send an electronic mail to your friends around the globe. The four essential components of data communications are a sender, a receiver, a channel, and a protocol. Sender => The computer that originates the message is called the sender. Receiver => The computer at the message’s destination is called the receiver.

33 Networks One of the most important types of data communications in the business world is a network connection. A network connects one computer to another computers and peripheral devices to share data and resources. There is a number of network configurations. local area network (LAN) => computers and peripheral devices are located relatively close to each other, generally in the same building. Client/server networks =>Some networks have file servers (one or more computers) that act as the central storage location for programs and that provide mass storage for most of the data used on the network. A network with a file server is called a client/server networks.

34 Networks Peer-to-peer networks => When a network does not have a file server, all the computers essentially are equal, and programs and data are distributed among them. This is called a peer-to-peer network. Each computer that is part of the network must have a network interface card installed. This device creates a communication channel between the computer and the network. Network software is also essential to establish the communications protocols. Standalone computer => A microcomputer that is not connected to a network is called a standalone computer.

35 Telecommunications Allows us to send and receive data over telephone lines. A modem connects a computer to a telephone jack. At the sending site, modem converts the digital signal from a computer into analog (continuous wave) signals (sound waves) that can traverse ordinary phone lines (modulation). At the receiving site, a second modem converts the analog signals back into digital signals (demodulation).

36 Telecommunications

37 Internet The internet was originally developed for the government to connect the researchers around the world to share data. Today, the internet is the largest network in the world that connects millions of people in almost 200 countries. The use of internet: electronic mail => This is the capability to send a message from one user’s computer to another user’s computer where it is stored until the receiver opens it. Message passes through electronic links called gateways. World Wide Web (Web) => Web is a huge database of information that is stored on the network servers in places that allow public access. The information is stored as text files called web pages.

38 Internet Hyperlinks => a place on a computer screen that is programmed to connect to a particular file on the same network server, or on a network server on the other side of the globe. Web browser => communication software that help us navigate the WWW is called web browsing software or web browser.

39 Computer Software Software consists of the computer programs that allow us to solve problems by providing sets of instructions. Examples: DOS, Windows, Mac. Office family, Lotus, Netscape, Internet Explorer, Virus scans, tax programs, computer games, GUI - Graphical User Interface.

40 Computer Software Computer hardware is useless without software.
Software is the set of instructions and associated data that direct the computer to do a task. Software can be divided into two categories: system software and application software. System software helps the computer carry out its basic operating tasks. Application software helps the user carry out a variety of tasks.

41 The major types of software
System Software Operating Systems Schedules computer events Allocates computer resources Monitor events Application software System software Hardware Language translators Interpreters Compilers Users Application Software Programming languages Assembly language FORTRAN, BASIC, PL/1 PASCAL, C “4th generation “ languages Utility programs Routine operations (e.g. sort, list, print) Manage data (e.g. create files, merge files

42 System Software Manages the fundamental operations of the computer, such as loading programs and data into memory, executing programs, saving data to disks, displaying information on the monitor, and transmitting data through a port to a peripheral device. Three types of system software: operating systems, utilities, device drivers.

43 Operating System Collection of computer programs that control the interaction of the user and the computer hardware. Responsible for directing all computer operations and managing all computer resources. Controls basic input and output, allocates system resources, manages storage space, maintains security, and detects equipment failure. A part of the operating system code is stored in a ROM and the rest of it resides on a disk. Loading the operating system into memory is called booting the computer.

44 Responsibilities of an Operating System
Communicate with user, receive and execute commands, show error messages. Manage allocation of memory, processor time and other resources. Collect input from keyboard, mouse, and provide data to running programs. Convey program output to screen, printer, or other output device. Access data from secondary storage. Write data to secondary storage.

45 Utilities Another category of system software.
Augments the OS by taking over some of its responsibility for allocating hardware resources. Many utilities come with OS. Some independent software developers offer utilities for sale separately. E.g. Norton Utilities by Symantec.

46 Device driver Each peripheral device requires a device driver.
Helps the computer communicate with that particular device. When we add a device to an existing computer, part of its installation includes adding its device driver to the configuration.

47 Computer programming languages
Programmer uses to write computer instructions. The instructions are converted into electrical signals that computer can manipulate and process. E.g. Basic, Visual Basic, C, C++, Cobol, etc.

48 Command-line & Graphical User Interfaces
Command-line interface systems display a command prompt, then expect the user to type the desired commands. These systems include UNIX, MS-DOS and VMS. Graphical user interfaces (GUI) display pictures (icons), menus, and text, which the user may point to with a mouse or other pointing device, then click to select the desired function. These systems (GUI) include Macintosh OS, Windows 95/98, Windows NT, OS/2 Warp, and Unix with X Windows interface.

49 Application software Developed for a specific task , such as word processing( MS Word/ WordPerfect), accounting (Lotus 1-2-3/ Excel), or database management (Access/ dBASE). Most applications are purchased on diskette or CD-ROM. They are installed by copying the programs from the diskettes/CD-ROM to the hard disk.

50 Computer Languages: Machine Language
Machine language: directly understood by a computer since it is a collection of binary numbers (0 and 1). Disadvantages: It is not standardized, different CPU needs different machine languages.

51 Assembly language One step above of machine language. More readable.
Computer operations are represented by mnemonic codes rather than binary numbers. Variables can be given names rather than binary memory addresses. Disadvantage: CPU- dependent.

52 High -level languages CPU-independent.
Combines algebraic expressions and English symbols. Disadvantage: computers do not understand. It must be translated into the target computer’s machine language before execution- compiler does the job.

53 Different High Level Languages
Some of the high-level languages available include: FORTRAN for scientific programming, COBOL for business data processing, LISP for list processing, C for systems programming, Prolog for artificial intelligence, ADA for real-time distributed systems, Smalltalk for graphical user interfaces and object-oriented programming, and C++ for object-oriented programming.

54 Compiler Software that translates a high-level language program into machine language. Input to the compiler is a source file (created by word processor or editor) containing the text of a high-level language program. If it is syntactically correct, compiler will save in an object file which is a machine language instructions for the same job.

55 Linker All machine instructions are not complete.
High-level language programs use at least one of the function that reside in other object files available to the system. Linker combines several object files, resolving cross references between the files, into one executable file (machine language program).

56 Loader To run an executable file, the loader must copy all the instructions into memory and direct the CPU to begin execution with the first instruction. As the program executes, it takes input data from source(s) and sends results to output devices.

57 Integrated development environment (IDE)
Most high-level languages now include an Integrated Development Environment (IDE) consisting of a simple word processor, compiler, linker and loader tools for finding errors. This software package provides menus from which user can select the next step. It leaves all versions of the program in memory. For safety, we need to explicitly save the source file to disk.

58 Program Execution Executing a program requires the CPU to examine each program instruction in memory and send out the command signals required to perform each instruction. Although instructions are normally performed consecutively (sequencing), they can be skipped (branching) or repeated (looping) under program control. During execution, data can be entered by the operator, or from a saved file. After processing, the program output can be displayed or printed as a result.


Download ppt "Introduction to Programming"

Similar presentations


Ads by Google