Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 1: Introduction to Computers. OBJECTIVES In this lecture you will learn:  Basic computer concepts.  The different types of programming languages.

Similar presentations


Presentation on theme: "Lecture 1: Introduction to Computers. OBJECTIVES In this lecture you will learn:  Basic computer concepts.  The different types of programming languages."— Presentation transcript:

1 Lecture 1: Introduction to Computers

2 OBJECTIVES In this lecture you will learn:  Basic computer concepts.  The different types of programming languages.  The influential programming languages.  The purpose of the C Standard Library.  The elements of a typical C program development environment.  To write simple computer programs in C.

3 What is a Computer? Computer Device capable of performing computations and making logical decisions. Processing data under the control of sets of instructions called computer programs. Hardware Various devices comprising a computer. Keyboard, screen, mouse, disks, memory, CD- ROM, and processing units. Software Programs that run on a computer.

4 Computer Organization Six logical units Input unit: Obtains information from input devices (keyboard, mouse) Output unit: Outputs information (to screen, printer, other devices) Memory unit : Rapid access, low capacity, temporarily storing information Arithmetic and logic unit (ALU ): Performs arithmetic calculations and logic decisions Central processing unit (CPU): Supervises and coordinates the whole computer Secondary storage unit Cheap, long-term, high-capacity storage Stores inactive programs 1)Monitor 2)Motherboard 3)CPU 4)Main memory 5)Expansion cards 6)Power supply unit 7)Optical disc drive 8)Hard disk drive 9)Keyborad 10)mouse

5 Motherboard and CPU

6 Operating Systems What is the OS? Resource allocator allows the proper use of resources (hardware, software,data) provides an environment in which other programs can do useful work Control program controls the execution of user programs to prevent errors and improper use of the computer controls the operation of I/O devices What is the purpose? Manage transitions between jobs Increasing throughput (amount of work processed)

7 Operating Systems - A Short History Simple batch systems Do only one job or task at a time. The programs and data were submitted in batches with punch cards. IBSYS (1950’s) Multi-programming (multi-tasking) batch systems Computer resources are shared by multiple jobs or tasks IBM’s OS/360 (early 1960’s) Time-sharing systems Computer runs a small portion of one user’s job then moves on to service the next user MIT’s CTSS (1962), Multics (1968), UNIX (1969) Personal computer systems Microprocessor technology evolved to the point that it become possible to build desktop computers as powerful as the mainframes of the 1970s. DOS (1980), Windows 3.0 (1990), Linux (1991)

8 Programming Languages Machine languages Strings of numbers giving machine specific instructions Example:+1300042774 +1400593419 +1200274027 Assembly languages English-like abbreviations representing elementary computer operations (translated via assemblers) Example:LOAD BASEPAY ADDOVERPAY STOREGROSSPAY Three types of programming languages. … … … BASEPAY OVERPAY GROSSPAY 2000 500 2500 RAM

9 Programming Languages High-level languages Codes similar to everyday English Use mathematical notations Example: grossPay = basePay + overTimePay Execution of high-level language programs Complier: to convert high-level language programs into machine language. Interpreter: to execute high-level language programs directly without compiling into machine language. Compiling takes a considerable amount of computer time. Compiled programs execute much faster than interpreted programs. Three types of programming languages (cont.)

10 Influential Programming Languages Fortran (IBM 1950s) Used for scientific and engineering applications require complex mathematical computations COBOL (1959) Used for commercial applications that require precise and efficient manipulation of large amounts of data Pascal (Prof. Niklaus Wirth, 1971) Designed for teaching structured programming Ada (DOD, 1970s and early 1980s) Able to perform multitasking C (late 1970s) Evolved from B (BCPL) by Dennis Ritchie at Bell Lab, 1972 Development language of UNIX Widely used to develop modern operating systems. Hardware independent (portable)

11 Influential Programming Languages C++ ( Bjarne Stroustrup at Bell Labs, 1983-1985 ) Superset of C, providing object-oriented capabilities Objects: reusable software components that model items in the real world. Object-oriented programming technique can make software development much more effective Dominant language in industry and academia JAVA ( Sun Microsystems, 1995 ) Create Web pages with dynamic and interactive content Develop large-scale enterprise applications Enhance the functionality of Web servers Provide applications for intelligent consumer devices (such as cell phones, pagers, and personal digital assistants)

12 C Standard Library C programs consist of pieces/modules called functions A programmer can create his/her own functions Pros: the programmer knows exactly how it works Cons: time consuming Programmers often use the C library functions to avoid re- inventing the wheel If a pre-made function exists, generally best to use it rather than write your own Library functions carefully written, efficient, and portable C standardization Many variation that were similar existed, and were incompatible across hardware platforms A standard version of C was needed ANSI/ISO C created in 1989 and updated in 1999

13 Typical C Program Development Environment Phases of C programming Edit Preprocess Compile Link Load Execute openSUSE gedit gcc

14 A Simple C Program /* and */ indicate comments – ignored by compiler #include directive tells C to load a particular file Left brace declares beginning of main function Statement tells C to perform an action return statement ends the function Right brace declares end of main function Every C program begins executing at the function main. Print a line of text Illustrate several important features of the C language

15 A Simple C Program Comments Text surrounded by /* and */ is ignored by compiler Used to describe program

16 A Simple C Program #include Preprocessor directive Tells computer to load contents of a certain file allows standard input/output operations

17 A Simple C Program int main() C programs contain one or more functions, exactly one of which must be main Parenthesis used to indicate a function int means that main "returns" an integer value Braces ({ and }) indicate a block The bodies of all functions must be contained in braces

18 A Simple C Program printf( "Welcome to C!\n" ); Entire line called a statement All statements must end with a semicolon (;) Instructs computer to perform an action prints the string of characters within quotes (" ") Escape character (\) \n is the newline character

19 Some Common Escape Sequences

20 A Simple C Program return 0; A way to exit a function return 0, in this case, means that the program terminated normally

21 A Simple C Program Right brace } Indicates end of main has been reached

22 Good Programming Practice Every function should be preceded by a comment describing the purpose of the function. Add a comment to the line containing the right brace “}” that closes every function, including main. The last character printed by a function that displays output should be a newline (\n). Ensures that the function will leave the screen cursor positioned at the beginning of a new line. Conventions of this nature encourage software reusability—a key goal in software development environments. Indent the entire body of each function one level of indentation within the braces that define the body of the function. Emphasizes the functional structure of programs Helps make programs easier to read Uniformly apply a fixed size of indent.

23 Example of Using “\n” printf statement starts printing from where the last statement ended, so the text is printed on one line. output

24 Example of Using “\n” Newline characters move the cursor to the next line output


Download ppt "Lecture 1: Introduction to Computers. OBJECTIVES In this lecture you will learn:  Basic computer concepts.  The different types of programming languages."

Similar presentations


Ads by Google