380 likes | 418 Views
Computer Science 1620. Syllabus, Introduction. Instructors. Lectures Robert Benkoczi Office D520 403-329-2298 robert.benkoczi@uleth.ca Labs, tutorials Arie Bomhof Office C510 403-329-5171 a.bomhof@uleth.ca. Textbook. C++ Programming Program Design Including Data Structures
E N D
Computer Science 1620 Syllabus, Introduction
Instructors Lectures Robert Benkoczi • Office D520 • 403-329-2298 • robert.benkoczi@uleth.ca Labs, tutorials Arie Bomhof • Office C510 • 403-329-5171 • a.bomhof@uleth.ca
Textbook C++ Programming Program Design Including Data Structures 4th Edition (this is a picture of 3rd ed) By: D.S. Malik • Copies have been ordered for the bookstore. • Not the first time this book has been used (so used copies may be out there).
Topics • Topics: • (approximate listing and order, scheduling depends on time constraints) • Introduction to Programming • C++ Basics • data types • expressions • variables • basic input/output • Control Structures • selection, iteration • Functions • parameter passing, return values, prototyping, reference parameters • Arrays & Strings • Structures & Classes
Grading Scheme • Programming Assignments (8) 32% • Midterm exam 20% • Final Exam 40% • 1 lab quiz 3% • 2 class quizzes 5% • CodeLab homework (bonus) 8% • Conversion to Letter Grades (may be revised):
Assignments • Assignments • 8 assignments, due Wednesdays 23:59 • 4% each • handed in electronically • Not easy! Do not attempt to finish in 1 afternoon • Academic Honesty • you are encouraged to work together to solve problems • however, you may not copy the work of another student. TA-s will look for similar code. • copying is a very serious offence … please refrain.
Codelab • Optional, but excellent learning tool for beginners. Will prepare you for assignments, midterm, and exam. • Example: URLs: www.tcgo1.com www.tcgo2.com
Exams • Midterm • Wed. Oct. 28 (usual lecture time and location) • closed book • 20% of your grade • Final • closed book • 40% of your grade • cumulative (covers everything from beginning) • no electronics allowed at exams (mp3, cell phones, etc) • picture ID (preferably a student card) required to write • Quizzes: short (10-15 min), in class, announced 1 week ahead of time.
Labs • Labs • hands-on experience with class concepts • opportunity to work on assignments with assistance • Linux/gcc concepts (not covered in class) • Tutorials: • supplement class material • interactive (Q & A) session) Class web page: www.cs.uleth.ca/~a.bomhof/cs1620A
Comments • No late assignments (except for medical reasons) • Plagiarism, copying, and misrepresentation are a serious offence, and can lead to severe penalties – refer to the course calendar for details. If in doubt about what constitutes cheating, please consult your instructor. • Students with special classroom or exam requirements should consult the calendar (Part 17, 12) for procedures on how to make such requests.
Comments • Please be respectful of your fellow students. • try to arrive at the lecture on time • please limit your discussion to class discussion during the lecture • please remember to turn off the sound on any electronic device (laptop, cell phone, etc). I will not answer questions about course material via e-mail. You are welcome to see me if you need help.
Computers • Man’s greatest invention? • Productivity • Computers perform many tasks faster and more efficiently than humans • Communication • We communicate with others all over the world quickly • Information • Terabytes of information are available at our fingertips
The progress of computers 1946 2007 • Laptop PC • $750 • 4 lbs • billons of ops/second • The ENIAC • $500,000 • 30 tonnes • 5000 ops/second
Desktop computers • Productivity software • Word processors • Spreadsheets • Information • Internet • Electronic resources (encyclopedias) • Games • etc How is all of this accomplished?
Computer Program • A sequence of instructions designed to perform a specific task, or collection of tasks • Eg. Microsoft Word • Monitors keyboard input, displays it on the screen • Formats input for more readable presentation • Spellchecks your work • Prints your work • Saves your work • ….
Computer Programming • The science (art) of constructing a program to achieve a specific goal • That is, for every program you have on your desktop PC, a programmer (team of programmers) had to create that program
Program • Step-by-step instructions to achieve the desired task(s) • Each instruction is executed by the processor
Hardware • Dr. John Von Neumann – Princeton University, 1946, proposed the concept of a stored program computer – a computer whose program is stored in computer memory. • This architecture is still the basis for today's digital computer. • Prior to this, the computer called the E.N.I.A.C (1946) could only be programmed by connecting wires and setting switches.
Von Neumann architecture • VN model: every computer is organized into four main parts • CPU - central processing unit • brains of the computer. • eg. Pentium 4, AMD Athlon • Main Memory • stores information being processed by the CPU • eg. 1 GByte • Secondary Storage • stores data and programs • eg. 200GByte Hard drive • Input/Output devices • allows people to supply information to and from computers • eg. printers, scanners, speakers, monitors, etc.
Example • Suppose we wish to perform the following calculation: • how do we program our computer to make this calculation? (17 + 29) x 56
Machine Code • the language of your processor • each line represents an instruction to be executed (this “code” is stored in the memory; CPU executes the instruction pointed by the Program Counter; after execution, the PC points to the next instruction, etc) place value "17" in memory location 1 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 place value "29" in memory location 2 add values in loc. 1 and 2, place in loc. 3 place value "56" in memory location 4 multiply values in loc. 3 and 4, place in loc. 5 • the solution to the problem is in memory location 5
Machine Code – Problems • 1) Difficult to read and write • the numeric version of each instruction must be remembered • each number must be translated to binary place value "17" in memory location 1 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 place value "29" in memory location 2 add values in loc. 1 and 2, place in loc. 3 place value "56" in memory location 4 multiply values in loc. 3 and 4, place in loc. 5
Machine Code – Problems • 2) Prone to error • mistaking a 1 for a 0 (or vice versa) can cause program failure • difficult to diagnose place value "17" in memory location 1 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 place value "29" in memory location 2 add values in loc. 1 and 2, place in loc. 3 place value "56" in memory location 4 multiply values in loc. 3 and 4, place in loc. 5 if these two bits are switched, addition will occur instead of multiplication
Machine Code – Problems • 3) Time Consuming • simple formula required 5 instructions • suppose you had a really complex task? 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 0000100100010001 0000101000011101 0001001100101000 0000110000111000
Machine Code – Problems • 4) Unnatural • machine instructions are quite far from natural language • not entirely intuitive what is being done • place value "17" in memory location 1 • place value "29" in memory location 2 means • add values in loc. 1 and 2, place in loc. 3 (17 + 29) x 56 • place value "56" in memory location 4 • multiply values in loc. 3 and 4, place in loc. 5
Machine-Specific • only processors implementing that specific instruction set can interpret the code This may not correspond to a load command on other processors. 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000
Assembly Code • close to machine code • differences • numbers can be written in a different base (decimal) • instruction type given readable name • instruction is separated visibly into components
Assembly Code Machine Code Assembly Code 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 load t1 17 load t2 29 add t3 t1 t2 load t4 56 mult t5 t3 t4 Note: A 1 to 1 instruction correspondence with machine code
Assembly Code to Machine Code • processor does not interpret assembly code • a separate program called an assembler translates the assembly code to machine code Assembler load t1 17 load t2 29 add t3 t1 t2 load t4 56 mult t5 t3 t4 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000
Assembly Code vs. Machine Code Machine Code Assembly Code • Symbolic representations of instructions and numbers easier to read • Symbolic representations of instructions and numbers reduce error • Time Consuming • Unnatural • Machine Specific • Difficult to read and write • Error Prone • Time Consuming • Unnatural • Machine Specific
High-Level Programming Language • e.g. C++, Java, Pascal • offers a more natural language for programming • commands are less coupled to the instructions of the processor
High-Level Programming Language (C++) Assembly Code C++ Code Machine Code 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 load t1 17 load t2 29 add t3 t1 t2 load t4 56 mult t5 t3 t4 (17 + 29) * 56;
HL Code to Machine Code • processor definitely does not interpret high-level code • a separate program called a compiler translates the code to machine code Compiler 0000100100010001 0000101000011101 0001001100101000 0000110000111000 0010010101110000 (17+29) * 56;
High-Level Code vs. Machine Code Machine Code High Level Code • Most of the instructions in C++ are English words (if, else, while, for, do) • numbers can be written in base 10, or 16, or 8, etc. • words and numbers easier to interpret • compiler flags all syntax errors for the programmer • Difficult to read and write • Error prone
High-Level Code vs. Machine Code Machine Code High Level Code • One C++ instruction often translates to many machine instructions • Existing C++ libraries are available for use and cut programming time dramatically • instructions are often English words • mathematical formulae can be written in familiar notation • Time Consuming • Unnatural
High-Level Code vs. Machine Code Machine Code High Level Code • C++ is universal • Only the compiler is machine-specific • Machine-specific
C++ • a "high-level language" • developed by Stroustrup • extended the "C" language • a very popular programming language • efficient – yet powerful