Introduction to Computers and Programming Language PDF

Summary

This document provides an introduction to computers and programming languages. It covers topics such as computer hardware and software, different programming language types, and program development. The document is well-suited for an undergraduate computer science course.

Full Transcript

Introduction to Computers And Programming Language Learning Outcomes At the end of this lecture, you should be able to: tell the purpose of computer programs. describe the hardware and software components of a computer system. tell about the language of a computer....

Introduction to Computers And Programming Language Learning Outcomes At the end of this lecture, you should be able to: tell the purpose of computer programs. describe the hardware and software components of a computer system. tell about the language of a computer. describe the evolution of programming languages. list the high-level programming languages. LECTURE 1 2 Learning Outcomes (cont.) At the end of this lecture, you should be able to: tell about the history of C++ language. recognize a C++ program. explain the different types of program errors. explain how a C++ program is processed and tested. explain what compiler, linker and loader are and what they do. LECTURE 1 3 Why Program? Computer – programmable machine designed to follow instructions. Program – a set of instructions for a computer to follow. – expressed in a language that the computer can understand. Programmer – person who writes instructions (program) to make computer perform a task. SO, without programmer, no program; without program, a computer cannot do anything. LECTURE 1 4 LECTURE 1 5 Computer Components Computer is an electronic device, with two major components. Computer Hardware Software LECTURE 1 6 Computer Hardware Hardware refers to the physical parts of the computer that have mass (they can be touched). Hardware for a typical computer system includes the following FIVE main categories : 1. Main Memory / Primary Storage / Internal Memory 2. Central Processing Unit (CPU) 3. Secondary Storage / Auxiliary Storage / External Memory 4. Input Devices 5. Output Devices LECTURE 1 7 Categories of Computer Hardware LECTURE 1 8 Main Memory Main memory stores the instructions and data of the programs that are running on the computer. Main memory’s content can change during program execution. It is volatile, which means the main memory’s content is erased when program terminates or computer is turned off. It is also called Random Access Memory (RAM) Main memory consists of long list of memory locations. −Each memory location is called a byte, which has eight bits (binary digits) that contains zeros and ones. −Binary Digit or Bit : A digit that can only be zero or one. LECTURE 1 9 LECTURE 1 10 Main Memory Data and instructions of programs are kept as binary digits in memory locations. − Each memory location has an address that is a unique number that identifies a memory location. Some data is too large for a single byte. – Most integers and real numbers are too large. – Next few consecutive bytes can store the additional bits for larger data. – Address of large data refers to the address of the first byte used by it. LECTURE 1 11 Illustration of Main Memory LECTURE 1 12 Central Processing Unit (CPU) Also known as Processor; ”Brain” of the computer. Comprised of: – Control Unit (CU) Retrieves, decodes and executes program instructions from RAM Coordinates activities of all other parts of computer – Arithmetic & Logic Unit (ALU) Hardware optimized for high-speed numeric calculation Hardware designed for true/false, yes/no decisions LECTURE 1 13 CPU Organization LECTURE 1 14 Secondary Storage Secondary memory stores instructions and data between sessions Non-volatile: data is preserved when program is not running, or computer is turned off. Comes in a variety of media: – magnetic: floppy disk drive (FDD), hard disk drive (HDD), magnetic tape drive – optical: Compact Disc (CD), Digital Video Disc (DVD) – flash memory : USB Flash drive LECTURE 1 15 Input Devices Devices that are sources to get input. Input is the information sent to the computer. Input consists of: – A program – Some data Many devices can provide INPUT: – Keyboard, mouse, scanner, digital camera, microphone, barcode reader, joystick – HDD, FDD, flash drive, magnetic tape, CD-ROM LECTURE 1 16 Output Devices Devices that send output. Output is information from the computer to the outside world. Many devices can be used for OUTPUT: – Computer monitor, printer, projector, speaker, headphone, plotter – HDD, FDD, flash drive, magnetic tape, CD-RW, DVD-RW LECTURE 1 17 Computer Software Software: refers to program that resides and executes electronically on the hardware. Software is divided into 2 categories: Software System Software Application Software LECTURE 1 18 System Software Normally supplied by the manufacturer of the computer. Software that manages computer hardware resources, and the programs that run on them. Basic types of system software: − BIOS, operating systems, utility programs, software development tools. The operating system is the most important type of system software. Without it, a user cannot run an application program on their computer, unless the application program is self booting. LECTURE 1 19 Operating System The operating system: − Is a program − Allows us to communicate with the computer − Allocates the computer’s resources − Responds to user requests to run other programs Common operating systems include: UNIX Linux DOS Windows Macintosh VMS LECTURE 1 20 Application Software Programs that provide services (problem solution) to the user. Designed to perform a specific task (e.g. : course registration system, banking system) OR a general- purpose task (e.g. : word processing, games). May be acquired by purchasing off-the-shelf or by designing for own purpose (custom made). Off-the-shelf software : Prewritten and ready to use. For general-purpose task. Custom made software: Written by in-house, consulting firm or software LECTURE 1 house. For specific task. 21 Where are the application and system software? LECTURE 1 22 Programs and Programming Languages A computer program is a set of written instructions given to a computer for it to follow. To write a program needs a programming language. Types of programming languages: – High-level: closer to human language – Low-level: used for communication with computer hardware directly. Often written in binary machine code (0’s/1’s) directly. LECTURE 1 23 The Language of a Computer Machine Language is the language of a computer. Machine Language consists of binary digits (bits); sequences of 0s and 1s. 0 (signal off) , 1 (signal on) Example : 1011010000000101 LECTURE 1 24 History Of Computer Languages Computer language evolution The only language understood by a computer is machine language LECTURE 1 25 History Of Computer Languages (cont.) 1. Machine Language Computer only understand this language. Series of 1’s and 0’s (binary numbers), such as 1011010000000101 Difficult to write. Low level language LECTURE 1 26 History Of Computer Languages (cont.) Early computers were programmed in machine language Using machine language, to calculate wages = rates x hours can be written as: 100100 010001 To load a Value 100110 010010 To multiply it with another value 100010 010011 To store the result LECTURE 1 27 History Of Computer Languages (cont.) 2. Symbolic/Assembly Language Unique to particular computer. Use mnemonics symbols. E.g. “MULT” –Multiply Easier to understand. LECTURE 1 28 History Of Computer Languages (cont.) Using assembly language instructions, wages = rates x hours can be written as: LOAD rate MULT hours STOR wages Must be translated to machine language (zeros and ones) for the CPU to execute a program written in assembly language. LECTURE 1 29 History Of Computer Languages (cont.) 3. High-Level Language Are designed to be easy to read and write. Programmers use this language to write programs. Compiler: is use to translate a program written in a high- level language to machine language Portable to many different computers. E.g. COBOL , FORTRAN , Visual Basic, Pascal, C, C++, C#, Java, Lisp, Ada The equation wages = rates x hours can be written in C++ as: wages = rate * hours; LECTURE 1 30 Some Well-Known High-Level Programming Languages LECTURE 1 31 History Of Computer Languages (cont.) 4. Natural Language Like our natural language (such as English, French, or Chinese) Its use is still quite limited. LECTURE 1 32 C++ History C++ evolved from C C++ designed by Bjarne Stroustrup at Bell Laboratories in early 1980s Overcame several shortcomings of C Incorporated object oriented programming C remains a subset of C++ C++ programs were not always portable from one compiler to another In mid-1998, ANSI/ISO C++ language standards were approved LECTURE 1 33 A Sample of C++ Program A simple C++ program begins this way: #include using namespace std; int main() { And ends this way: return 0; } LECTURE 1 34 Example of a C++ Program #include using namespace std; int main() { cout

Use Quizgecko on...
Browser
Browser