Documente Academic
Documente Profesional
Documente Cultură
Jameel Ahmad Assistant Professor Jameel.ahmad@umt.edu.pk Department of Electrical Engineering University of Management and Technology
CS141-Programming Fundamentals
Required Textbook: C How to Program 5th or 6th edition Paul Deitel and Harvey Dietel
CS141-Programming Fundamentals
Grading Policy
Labs (attendance + task completion): 20% Quizzes : 10% Assignments: 15% Mid Term: 15% Final Exam (Code + Conceptual): 40%
CS141-Programming Fundamentals
Student Civility
In an effort to make this class enjoyable for
everybody
Please be on time to class!
class! It disturbs everyone, and makes it hard to concentrate. If you have a question, just ask me! Please turn your pagers and cell-phones off!
5
CS141-Programming Fundamentals
you want to discuss some issue Option 1: Come to my Office Hours Option 2:Send me an email
Course Description
Introduction to algorithms and programming What is an algorithm? What is programming? Programming philosophy How to think of a programming problem How to plan the solution to the problem
CS141-Programming Fundamentals
CS141-Programming Fundamentals
iteration/looping)
CS141-Programming Fundamentals
Course Objectives
Understand basic components in a computer
architecture Appreciate the role of programming languages Design a top-down solution for solving problems Be familiar with an IDE Edit, compile, debug and run short programs
CS141-Programming Fundamentals
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
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
CS141-Programming Fundamentals
System Software
Compilers, Interpreters,Preprocessors, etc. Operating System, Device Drivers
CS141-Programming Fundamentals
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
Computer Languages
Machine Language
Uses binary code Machine-dependent Not portable
Assembly Language
Uses mnemonics Machine-dependent Not usually portable
Uses English-like language Machine independent Portable (but must be compiled for different platforms) Examples: Pascal, C, C++, Java, Fortran, . . .
CS141-Programming Fundamentals
PL hierarchy
CS141-Programming Fundamentals
Assembly languages English-like abbreviations representing elementary computer operations (translated via assemblers) Example:
LOAD ADD STORE
2000 Prentice Hall, Inc. All rights reserved.
CS141-Programming Fundamentals
English is a natural language. Although high level programming languages are closer to natural languages, it is difficult to get too close due to the ambiguities in natural languages (a statement in English can mean different things to different people obviously that is unacceptable for computer programming). However, this is a big research area of computer science.
Machine Language
instructions.
Instructions:
Machine instructions are in binary code
Instructions specify operations and memory cells involved in the
operation
Example:
Operation
Address
CS141-Programming Fundamentals
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 errorprone but is more efficient in terms of hardware performance. Mnemonic representation of the instructions and data Example:
Load Add Store Price Tax Cost
CS141-Programming Fundamentals
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
CS141-Programming Fundamentals
the rules for their combination, simple and regular (conceptual integrity). readability
Orthogonality
Being able to combine various features of a language in
Simplicity
Safety (no goto, no pointers) Robustness (undesired events can be trapped, like
Maintainability
Factoring (modularity) Locality
Efficiency
CS141-Programming Fundamentals
Binary number
<binary_number> <bit> =0|1 = <bit> | <bit> <binary_number>
Identifier
<identifier> = <letter> {<letter> | <digit> } <letter> =a|b|...|z <digit =0|1|...|9
Semantics:
The meaning of the language
CS141-Programming Fundamentals
WARNINGS: 1. An algo. can be syntactically correct, yet semantically incorrect very dangerous situation! 2. Syntactic correctness is easier to check as compared with semantic
27
Syntax is correct
Semantics:
a formal language.
E.g. Backus-Naur Form (BNF)
implemented by a compiler to enforce grammar restrictions. Some PLs look more like grammar descriptions than like instructions.
CS141-Programming Fundamentals