Introduction to Programming PDF

Summary

This document is an outline for an introductory computer programming course. It details course objectives, topics to be covered, and a brief overview of computer history, hardware, and software. The course appears to be taught at a university level.

Full Transcript

Introduction to Programming Dr. Samar A. Said INSTRUCTOR INFORMATION Dr. Samar A. Said E-mail: [email protected] Course information Name : Introduction to programming Lecture hrs. : 2 hrs/week, COURSE ASSES...

Introduction to Programming Dr. Samar A. Said INSTRUCTOR INFORMATION Dr. Samar A. Said E-mail: [email protected] Course information Name : Introduction to programming Lecture hrs. : 2 hrs/week, COURSE ASSESSMENT Total degree 100 Grading: Midterm exam Quizzes Assignments 50 marks Participation Final exam 50 marks COURSE OBJECTIVES Objectives: Learn basic computer operations Identify the basic components of a computer and its functions Explain the characteristics of computers Differentiate between a hardware and a software Explain the importance of operating system Learn information representation in computer system Study Logic gates to design simple digital circuits Learn problem solving process Improve the programming skills they need for research in earth sciences or engineering. Use the computer to solve problems. POINTS TO BE COVERED: Course objectives What is a computer? Data vs. Information Computer’s history Classification of computers Computer users and professionals Hardware vs. Software Inside the system unit The primary components of computer How the CPU works Making computers faster and better now and in the future Programming languages Outline of course content WHAT IS A COMPUTER? A computer automatically accepts data & instructions as input from an input device, stores them temporarily in its memory, then processes that data according to the instructions given, and finally transfers the processed data (information) to an output device. Computers process data under the control of sets of instructions called computer programs DATA VS. INFORMATION Data – raw, unorganized facts – can be in the form of text, graphics, audio, or video Information – data that has been processed into a meaningful form Information processing – converting data into information E.G. Students grades in a certain course, booked seats in a flight to Cairo. COMPUTER’S HISTORY The evolution of computing machinery has taken place over several centuries. The evolution of computers is usually classified into different generations according to the technology of the era. Computer generations First-generation computers (1946-1957) Second-generation computers (1958-1963) Third-generation computers (1964-1970) Fourth-generation computers (1971-present) Fifth-generation (the present and future ) FIRST-GENERATION COMPUTERS First-generation computers (1946-1957) Enormous and powered by vacuum tubes (an electronic device that controls the flow of electrons in a vacuum) Used a great deal of electricity, and generated a lot of heat ENIAC (Electronic Numerical Integrator And Computer) and UNIVAC (Universal Automatic Computer) SECOND-GENERATION COMPUTERS Second-generation computers (1958-1963) Used transistors (an electronic component that can be used as an amplifier or as a switch) Computers were smaller, more powerful, cheaper, more efficient, and more reliable Punch cards and magnetic tape were used to input and store data THIRD-GENERATION COMPUTERS Third-generation computers (1964-1970) Used integrated circuits (IC) - a small electronic circuit printed on a chip (usually made of silicon) that contains many its own circuit elements (e.g. transistors, diodes, resistors, etc.). Small & medium scale integration (IC) Keyboards and monitors introduced FOURTH-GENERATION COMPUTERS Fourth-generation computers (1971-present) Very large scale integration (VLSI) Use microprocessors IBM PC, apple macintosh Use keyboards, mice, monitors, and printers Use magnetic disks, flash memory, and optical disks for storage Computer networks, wireless technologies, internet introduced FIFTH-GENERATION COMPUTERS Fifth-generation computers (the present and future ) Based on artificial intelligence Uses the ultra large-scale integration (ULSI) technology and parallel processing method. UlSI– millions of transistors on a single microchip CLASSIFICATION OF COMPUTERS Computers are classified into Five basic categories : – Embedded computers – Mobile devices – Personal computers – Servers – Supercomputers CLASSIFICATION OF COMPUTERS Embedded computers Embedded into a product and designed to perform specific tasks or functions for that product Cannot be used as general-purpose computers Often embedded into Household appliances: washing machines, tvs, microwave ovens etc. Cars: blind spot warning, auto break systems, auto park systems etc. CLASSIFICATION OF COMPUTERS Mobile device A very small device with some type of built-in computing or internet capability Typically has a small screen and keyboard Examples: Smartphones Handheld gaming devices Media tablets CLASSIFICATION OF COMPUTERS Personal computer (PC) Small computer designed to be used by one person at a time Also called a microcomputer Available in different sizes and shapes Desktop computers On or next to a desk PC or macintosh Portable computers Designed to be carried Around easily CLASSIFICATION OF COMPUTERS Server A medium-sized computer used to host programs and data for a small network. Used in small- to medium-sized businesses such as medical or dental offices, as well as in school computer labs. Sometimes referred to as a minicomputer. Users connect via a network with a computer, thin client, or dumb terminal. CLASSIFICATION OF COMPUTERS Supercomputer Some applications require extraordinary speed, accuracy, and processing capabilities e.G. Controlling missile guidance systems and satellites, forecasting the weather, exploring for oil, breaking codes Fastest, most expensive, most powerful type of computer Generally run one program at a time, as fast as possible Can cost several million dollars each Tend to be very large and contain a large number of CPUs COMPUTER USERS AND PROFESSIONALS Computer users (end users) People who use a computer to obtain information Computer professionals include: Programmers Write programs computers use Systems analysts Design computer systems Security specialists Secure computers and networks against hackers HARDWARE VERSUS SOFTWARE Hardware – the physical parts of a computer Various devices comprising a computer Keyboard, screen, mouse, disks, memory, CD-ROM, and processing units Software – the programs or instructions used to tell the computer hardware what to do Programs that run a computer COMPUTER HARDWARE Hardware Internal hardware Located inside the main box (system unit) of the computer External hardware Located outside the system unit Connect to the computer via a wired or wireless connection COMPUTER HARDWARE A computer consists of the following parts/devices: Input devices. Output devices. Central processing unit (containing the control unit and the arithmetic/logic unit). Memory (main memory). Storage devices (secondary memory). Communications devices THE PRIMARY COMPONENTS OF A COMPUTER (INPUT DEVICES) 1) input devices. These are the devices used to enter/put data into the computer. They accept data for processing & convert it into a suitable form that the computer can understand. Examples: keyboard, mouse, joysticks, light pen, scanner, etc. THE PRIMARY COMPONENTS OF A COMPUTER(OUTPUT DEVICES) 2) output devices. Output devices are used to give the end results of data that was entered into the computer. They extract/ disseminate processed data (information) from the computer. They accept data from processing devices & convert it into human sensible form. Examples: screens (monitors), printers, graph plotters, speakers, etc THE PRIMARY COMPONENTS OF A COMPUTER(CPU) 3)the central processing unit: The central processing unit (CPU) contains electronic circuits that cause processing to occur. The cpu interprets instructions to the computer, performs the logical and arithmetic processing operations, and causes the input and output operations to occur. It is considered the “brain” of the computer. Dual-core cpu: contain the processing components (cores) of two separate processors on a single cpu Quad-core CPU: contains 4 cores THE PRIMARY COMPONENTS OF A COMPUTER (MEMORY) 4)memory: This is the storage found within the computer itself. It is used to hold data, programs & instructions required immediately (or currently being used) by the processor. Examples: random access memory (ram) & read only memory (rom) THE PRIMARY COMPONENTS OF A COMPUTER (SECONDARY STORAGE DEVICES). 5) secondary storage devices :they are permanent storage devices. Types of secondary storage devices: Magnetic Floppy disks Hard disks Optical Cd-rom Dvd MEMORY HIERARCHY Characteristics of storage devices Speed Volatility Access time Cost and capacity COMMUNICATIONS DEVICES Allow users to communicate with others and to electronically access remote information Modems, network adapters, routers, etc. COMPUTER SOFTWARE Computer Software System software Operating system starts up the computer and controls its operation Without OS, computer cannot function Boots the computer and launches programs at the user’s direction Most use a GUI to interact with the user via icons, buttons, tiles, etc. Windows, mac os, linux, android, etc. COMPUTER SOFTWARE Application software Performs specific tasks or applications Creating letters, budgets, etc. Editing photographs Exchanging e-mail Playing games Examples of application software Word processing programs Multimedia programs Web browsers E-mail programs INSIDE THE SYSTEM UNIT System unit: the main case of a computer Houses the processing hardware for a computer Also contains memory, the power supply, cooling fans, and interfaces to connect peripheral devices Houses the drive bays in which storage devices (hard drives, DVD drives, etc.) 35 INSIDE THE SYSTEM UNIT 36 BASIC UNITS OF MEASUREMENT Bit on OR off Binary digit Two possible values 0 1 Byte 8 bits MEMORY AND STORAGE MEASUREMENT Note: powers of two are used because computer memory and storage are based on the basic unit (bit). Kilobyte (kb) – a thousand bytes (1,024 = 210) Megabyte (MB) - a million (1,048,576 = 220) Gigabyte (GB) – a billion (1,073,741,824 = 230) Terabyte (TB) – a trillion (1,099,511,627,776 = 240) PROCESSOR AND MEMORY SPEED MEASURMENTS Millisecond (ms) – a thousandth of a second (1/1,000 = 10-3) Microsecond (μs) - a millionth of a second (1/1,000,000 = 10-6) Nanosecond (ns) – a billionth of a second (1/1,000,000,000 = 10-9) LOOK INSIDE YOUR COMPUTER Bus Structure Of Microcomputer The major parts of microcomputers are central processing unit (CPU), memory, and input and output unit. To connect these parts together through three sets of parallel lines, called buses. Bus: An electronic path within a computer over which data travels There are normally three types of bus in any processor system: 1. Address Bus 2. Data Bus 3. Control Bus 41 BUSES Address bus: It is a group of wires or lines that are used to transfer the addresses of memory or I/O devices. It is unidirectional this determines the location in memory that the processor will read data from or write data to. The number of memory location is depends on 2 to the power n address lines. Example, a cpu with 16 address lines can address 2^16 or 65,536 memory locations. Data bus: As name tells that it is used to transfer data within microprocessor and memory/input or output devices. It is bidirectional as microprocessor requires to send or receive data. Control bus: This manages the information flow between components indicating whether the operation is a read or a write and ensuring that the operation happens at the right time. PORTS AND CONNECTORS Port: A connector on the exterior of a pc’s system unit to which a device may be attached 43 HOW THE CPU WORKS CPU: consists of a variety of circuitry and components packaged together Transistor: key element of the microprocessor Today’s CPUs contain hundreds of millions of transistors; the number doubles about every 18 months (moore’s law) Typical CPU components Prefetch unit: tries to fetch data and instructions before they are needed Decode unit: translates instructions so they are understood by the control unit, ALU, and FPU Control unit: coordinates and controls activities Arithmetic/logic unit (ALU): performs integer arithmetic and logical operations Floating point unit (FPU): performs decimal arithmetic Internal cache and registers: store data and instructions needed by the CPU 44 Bus interface unit: where data and instructions flow in and out of the CPU TYPICAL CPU COMPONENTS 45 THE MACHINE CYCLE 46 MAKING COMPUTERS FASTER AND BETTER NOW AND IN THE FUTURE Improving performance today Add more memory Perform system maintenance Uninstall programs properly Consider placing large files on external storage devices Delete temporary files Arrange files efficiently Scan for viruses and spyware Empty the recycle bin Buy a larger or second hard drive Upgrade your internet connection Upgrade your video graphics card 47 MAKING COMPUTERS FASTER AND BETTER NOW AND IN THE FUTURE Strategies for faster and better computers Improved architecture: smaller components, faster bus speeds, multiple CPU cores, etc. Pipelining: allows multiple instructions to be processed at one time Multiprocessing and parallel 48 COMPUTER LANGUAGES Low level (processor dependent) Machine code, assembley High level: Structured Fortran, C, pascal… Object Oriented Programming (OOP) C++, java, C#,… MACHINE LANGUAGE The representation of a computer program which is actually read and understood by the computer. A program in machine code consists of a sequence of machine instructions. Instructions: Machine instructions are in binary code Instructions specify operations and memory cells involved in the operation Example: Operation Address 0010 0000 0000 0100 0100 0000 0000 0101 0011 0000 0000 0110 ASSEMBLY LANGUAGE A symbolic representation of the machine language of a specific processor. Is converted to machine code by an assembler. Usually, each line of assembly code produces one machine instruction (one-to-one correspondence). Programming in assembly language is slow and error-prone but is more efficient in terms of hardware performance. Mnemonic representation of the instructions and data Example: Load price Addtax Store cost HIGH-LEVEL LANGUAGE Programming language which use statements consisting of english-like keywords such as "FOR", "PRINT" or “IF“,... etc. Each statement corresponds to several machine language instructions (one-to-many correspondence). Much easier to program than in assembly language. Data are referenced using descriptive names Operations can be described using familiar symbols Example: Cost := price + tax HIGH-LEVEL LANGUAGE (STRUCTURED) Structured design: Dividing a problem into smaller subproblems Structured programming: Implementing a structured design The structured design approach is also called: Top-down (or bottom-up) design Stepwise refinement Modular programming HIGH-LEVEL LANGUAGE (OOP) Identify components called objects Specify relevant data and possible operations to be performed on that data Each object consists of data and operations on that data An object combines data and operations on the data into a single unit A programming language that implements OOP is called an object-oriented programming (OOP) language OUTLINE OF COURSE Contents going to be covered during course: Introduction to computer Numbering systems How to write C++ program and I/O Condition in C++ Loop in C++ Logic gates and Boolean algebra.

Use Quizgecko on...
Browser
Browser