Lec00 Intro
Lec00 Intro
Lec00 Intro
Attention to Detail
Good Memory
Syntax Standard functions Defined variables and functions Techniques
Need to compartmentalize tasks: little black boxes Solve big problems by solving the little problems Be aware of the assumptions made
PRACTICE PRACTICE
You don't learn how to play play the piano by reading a book. You don't learn how to play basketball by watching ESPN.
PRACTICE
projecteuler.net
Use your time in the laboratory wisely Have access to a computer outside lab hours. Have F U N
Course Outline
C Programming
Syntax Variables and data types Operators, expressions and statements Control structures
Course Outline
THIRD EXAM Dynamic Data Structures Memory and Pointers Linked Lists Trees Others File I/O Searching and Sorting UNIX/Linux environment
Grading System
Final grade
1.0 1.25 1.50 1.75 2.0 72 - <76 68 - <72 64 - <68 60 - <64 <60 2.25 2.50 2.75 3.0 5.0
Textbooks
C for engineers and scientists, Cheng, 2009 The Joy of C 3/e, Miller & Quilici, 1997 C: How to Program 6/e, Dietel & Dietel, 2010 C by Dissection 4/e, Kelley & Pohl, 2000 C Programming Language, Kernighan & Ritchie, 1988 ... actually, any book in C is better than having no book at all!
Class Policies
Students must read and comply with the UP Acceptable Use Policy (AUP). No make-up or final exam will be given. Students who arrive 30 mins late after the start of the exam will NOT be allowed to take the exam.
Class Policies
Attendance will be checked every lecture meeting. A student found absent more than 20% of the total course time (around 3 lecture/lab meetings) may be given a failing grade. Cheating in the exam, machine exercises and machine problems is punishable with a grade of 5.0 and is grounds for suspension/expulsion. Avoid talking in class. Keep your phone in silent mode, or turn it off when the class is in session. No eating and drinking inside the lecture halls.
EEE 11
What is a computer?
A programmable machine that responds to a specific set of instructions in a well-defined manner and can execute a prerecorded list of instructions (a program) Anything that computes
e.g. calculator
EEE 11
16
500 B.C.- Abacus 1600s - Blaise Pascal and Gottfried Leibniz mechanical calculators 1800s - Joseph Jacquard programmable weaving loom - Charles Babbage's analytical engine - punch card system 1940 - John Atanasoff's computer using boolean algebra 1943 - First electronic computer ENIAC Electronic Numerical Integrator and Computer 1951 - John von Neumann architecture: stored-program computers
EEE 11
17
Early computers
ENIAC (1946)
17,468 vacuum tubes, 150kW
EEE 11
18
1950s 1957 1962 1964 1968 1969 1970 1972 1973 1974
- 1st commercial computer (IBM) - Advanced Research Project Agency (ARPA) - Space War = 1st computer game st - IBM System/360 = 1 OS - ARPANET at UCLA - UNIX OS by AT&T Bell Labs - UCLA introduces the Internet - Intel produces 1st microprocessor - Mouse is patented - Pong by Atari = 1st commercial video game st - Xerox develops 1 GUI system - TCP is published
19
EEE 11
EEE 11
- Microsoft is established - Apple Computers founded; Apple I released - Apple II with colored graphics is introduced - 1st commercial network ARCNET - TCP splits to TCP/IP; UDP created - Apple DOS 3.1 (1st OS of Apple computers) - VisiCalc (early version of spreadsheets) - Wordstar (word processor) - IBM personal computers are introduced using MS-DOS - Wordperfect 1.0; Lotus 1-2-3 - ARPANET standardizes TCP/IP (birth of the modern internet) 20 - MS Windows
- IBM releases 1st portable computer (30 lbs) - 1st MUD is released - Appletalk is released - Nintendo Entertainment System (NES) - Linux is introduced - Windows 3.1 - DOOM was released st (turning point of 1 person shooter) - Netscape was established - Yahoo search engine - Windows 95 and IE 1.0 - IEEE 802.11 Wifi standard - Google is released
21
EEE 11
Moore's Law
The number of transistors on a chip will double every 18 to 24 months -Gordon Moore, 1965
EEE 11
22
Transistor Counts
Source: Intel
EEE 11
23
EEE 11
24
Desktop Computer
EEE 11
25
Inside Your PC
EEE 11
26
+,-,/,* compare
EEE 11
Control Primary storage Main memory Volatile Processor Fast expensive, low capacity RAM Secondary storage Non-volatile Cheap, high capacity Generally slower
coordinator
27
Hardware vs Software
Hardware
Refers to objects that you can actually touch disks, disk drives, display screens, keyboards, printers, boards, and chips
Software
Untouchable / intangible component of a computer exists as ideas, concepts, and symbols, but it has no substance
EEE 11
28
A computer without software is like a book full of blank pages Software to makes the computer useful
EEE 11 29
Interpreter
Object files
Linker
Binaries / Executable
Compilers vs Interpreters
Compiler
looks at the entire piece of source code collects and reorganize the instructions to increase efficiency (if possible)
Interpreter
analyzes and executes each line of source code Checks validity of the code
EEE 11
31
First generation: machine language form directly understandable by the computers processor (series of 1s & 0s) processor dependent Second generation: assembly language mnemonic system to represent the machine language instructions an assembly process translated the encoded instructions into machine language
32
EEE 11
Third generation programming languages (3GL) use of compilers and interpreters to translate statements into machine language Procedure-oriented
COBOL, FORTRAN, C, BASIC, Pascal, Ada, LISP, Prolog Java, C++, Python, C#
Object-Oriented
Fourth generation programming languages (4GL) closer to human languages require fewer commands to perform a given task
33
EEE 11
Number Representation
Computers can only process numbers Real-world data are normally mapped to numerical values
EEE 11
34
Each digit is assigned a weight dependent on its position relative to a radix point Set of symbols consisting of r elements are used to represent each digit
Example: 678.91
Conversion to Decimal
Multiply each binary digit by its weight, then add all the products Mathematical representation: Let ABCDE be a 5-digit number in base r then the value of ABCDEr is A r4 + B r3 + C r2 + D r1 + E r0
EEE 11
36
EEE 11
Hexadecimal (Base 16 )
Digits include 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 Use A = 10 B = 11 C = 12 D = 13 E = 14 F = 15 e.g. ABC16 = 10x162 + 11x161 + 12x160 = 2,748
39
EEE 11
Continuously divide the integer portion of the number by r. Note the remainder after each division The resulting number are just the remainders from the last to first (left to right).
EEE 11
40
Examples
7710 = ( ? )2 2 /77 2 /38 1 2 /19 0 2 /9 1 2 /4 1 2 /2 0 1 0 ANS: 10011012 5610 = ( ? )2 2 /56 2 /28 0 2 /14 0 2 /7 0 2 /3 1 2 /1 1 0 1 ANS: 1110002
EEE 11
41
Simplified Derivation
Let this equal to ABCDE in binary e.g. K=1310 = 011012 (A=0, B=1, C=1,D=0,E=1) = 24A + 23B + 22C +21D+20E = 23A + 22B + 21C +20D remainder E = 23A + 22B + 21C +20D = 22 A + 21 B + 2 0 C remainder D
42
Continuously MULTIPLY the fractional portion of the number by r. Note the integer portion after each multiplication the remove it from the number The resulting number is just the integer parts extracted while multiplying
EEE 11
43
Example
0.710 = ( ? )2 , up to 5 bits after the binary point 2 * .7 = 1.4 2 * .4 = 0.8 2 * .8 = 1.6 2 * .6 = 1.2 2 * .2 = 0.4 1 0 1 1 0
Answer: 0.101102
EEE 11
44
Simplified Derivation
Let this equal to 0.ABC... in binary e.g. K=0.6410 = 0.101...2 (A=1, B=0, C=1) = 2-1A + 2-2B + 2-3C ... = A + 2-1B + 2-2C ... = 2-1B + 2-2C ... = B + 2-1C
K 2K L 2L ...
EEE 11
A = whole # B = whole #
45
Mixed numbers?
EEE 11
46
e.g. 58 = 1012
Simply replace the octal digit with the corresponding binary digits and vice-versa
Octal 0 1 2 3 4 5 6 7 Binary 000 001 010 011 100 101 110 111
EEE 11
47
Example
1 2 5 0 6 1 78 = ( ? )2 111 001 110 000 101 010 001 001 010 101 000 110 001 111 2
48
= = = = = = = Answer =
EEE 11
EEE 11
Example
E 2 5A 6 1 716 = ( ? )2 = 0111 = 0001 = 0110 = 1010 = 0101 = 0010 = 1110 Answer = 1110 0010 0101 1010 0110 0001 0111 2
EEE 11 50
Expand first to binary then group by 4 or 3 depending on the destination e.g. ABC16 = (?)8 = A B C 16 = 1010 1011 1100 2 regroup by 3's ... = 101 010 111 100 2 = 5 2 7 48 = 5274 8
EEE 11
51
Credits
The Center for Programmers and Users. Fundamentals of Programming Hand-out 1 http://www.howstuffworks.com Definitions from: http://www.webopedia.com Flowchart examples from: http://www.eng.iastate.edu/efmd/161algor.htm#examples Additional reading: http://en.wikipedia.org/wiki/Computer
EEE 11 52