Introduction_To_C.ppt
Document Details
Uploaded by Deleted User
Tags
Full Transcript
Introduction to Computer Programming By: Dr. Abhishek Singh Outline of Topics Hardware/Software interface – Layers of the Machine – Kinds of Software Computer Languages Syntax, Semantics, Grammars What happens to your program? – Compilation, Linking,...
Introduction to Computer Programming By: Dr. Abhishek Singh Outline of Topics Hardware/Software interface – Layers of the Machine – Kinds of Software Computer Languages Syntax, Semantics, Grammars What happens to your program? – Compilation, Linking, Execution – Program errors Compilation vs. Interpretation etc. Software Categories System SW – Programs written for computer systems Compilers, operating systems, … Application SW – Programs written for computer users Word-processors, spreadsheets, & other application packages A Layered View of the Computer Application Programs Word-Processors, Spreadsheets, Database Software, IDEs, etc… System Software Compilers, Interpreters,Preprocessors, etc. Operating System, Device Drivers Machine with all its hardware Operating System (OS) Provides several essential services: – Loading & running application programs – Allocating memory & processor time – Providing input & output facilities – Managing files of information Programs Programs are written in programming languages – PL = programming language – Pieces of the same program can be written in different PLs Languages closer to the machine can be more efficient As long as they agree on how to communicate A PL is – A special purpose and limited language – A set of rules and symbols used to construct a computer program – A language used to interact with the computer Computer Languages – Machine Language Uses binary code Machine-dependent Not portable Assembly Language – Uses mnemonics – Machine-dependent – Not usually portable High-Level Language (HLL) – Uses English-like language – Machine independent – Portable (but must be compiled for different platforms) – Examples: Pascal, C, C++, Java, Fortran,... 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 Add Tax Store Cost Sample Assembly code for Printing Hello World High-level language A 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 Syntax & Semantics Syntax: – The structure of strings in some language. A language's syntax is described by a grammar. – Examples: Binary number = | =0|1 Identifier = { | } =a|b|...|z