Title: TA Office hours
1TA Office hours
2Reminders
- Course web site (all course information)
- http//classes.engr.oregonstate.edu/eecs/
- Then select CS151-001
- Black Board
- quizzes, email, announcements
- http//my.oregonstate.edu/
- engr account
- Programming assignments will be posted starting
on Monday - Programs are handed in at https//engr.orst.edu/
3Blackboard ONID
- You need to sign up for an ONID (OSU Network ID)
account at - http//www.onid.orst.edu/
- Then login to Blackboard at
- http//my.oregonstate.edu/
- Take Quiz 1 starting Monday on Blackboard.
- You may take the quiz as often as you like. It
is a learning tool. You must get a score of at
least 8 for the quiz to count.
4Program Assignments
- Find them at
- http//classes.engr.oregonstate.edu/eece/cs151-001
- programs due Friday by 1159 pm. ...
5Programming at Home
- Only if you know what you are doing .
- Limited help from me or TAs.
- We have limited supply of version 7 compilers for
those with demonstrated need. - You'll need to install a cs151 template.
- Best to test and submit from lab (CodeWarrior
version 8).
6What
- Introduction to programming
- Program
- A magical spell cast over a computer allowing it
to turn one's input into error messages. - Programming
- A pastime similar to banging one's head against
the brick wall with less productive results.
7How
- Lecture (important)
- Reading (very important)
- Quizzes (very important)
- Programs (absolutely indispensible)
- Exams (to test what you've learned) ...
8How Learn by Doing!
- Can only learn by doing.
- Study understand applications in book.
- Suggest running at least one application from
each chapter under CodeWarrior. - Understand examples from class.
9Why C Language?
- Efficient language (fast and compact).
- Extremely flexible.
- Good primer for learning C, Java, JavaScript,
C, Perl, PHP, etc. - real programming
10CodeWarrior - The Main Tool
- IDE - Integrated Development Environment
- Editor (for writing programs)
- Compiler (for translating into executables)
- Organizer (for organizing projects)
- Debugger (for finding and fixing bugs)
- Complex tool.
- Learn it early - pgm1 and exercises in book...
11Computers Programs
Computer
32 address wires
Memory
Computer Processing Unit (cpu)
1 2 3 5 6 7 8 9
32 data wires
instructions data
PC
- Connect to Program Counter address
- Load (fetch) instruction
- Execute instruction
- Increment Program Counter
Program
12All instructions and data are just on/off
switches inside the computer.
- Sometimes represented for humans as zeros and
ones 0 off, 1 on - Example 01011001 represents the number 89 or
instruction number 89 or character Y
depending on how it is used - Nobody wants to write programs using only zeros
and ones. - so programming languages and compilers were
invented
13Languages
assembly language
machine language
address
000000010110 PUSH SS 000101010100 PUSH
SP 000201010010 PUSH DX 000301000001 INC
CX 00040000000000000111 ADD BX,AL
Address Location of data in memory Machine
Lang Numbers assigned to instructions Assembly
Lang Symbolic (text) representation
of instructions.
14High Level Languages (HLL)
- Translators
- Assembler (Assembly Lang -gt Machine Lang)
- Compiler/Linker (HLL -gt Machine Lang)
- Interpreter (Executes HLL directly)
- HLLs
- ADA, BASIC, C, C, COBOL, EIFFEL,
- FORTRAN, JAVA, LISP, PASCAL, PERL
- PHP, PROLOG, SCHEME, Tcl/Tk ...
15Programming in HLL
- Write program text using an editor.
- Translate program into machine language using a
compiler (machine specific). - Connect the machine code to built-in functions
(e.g., input/output) using a linker. - Load the program into memory.
- Execute.
16Compiling Process
- Compile - Translate from source text file into
object format. Addresses of instructions and
data not yet fixed. - Link - Combine multiple object files in such a
way to make a complete executable program (i.e. a
file with .exe suffix which will run when
double-clicked). ...
17Create compile link load - execute
Libraries
Idea
Linker
Executable code
Text editor
Source code
Compiler
Operating system loads executable program into
the computers memory, and starts execution
Object code
18Using C under CodeWarrior
Computer
19Using C under CodeWarrior
Computer
Windows (operating system)
20Using C under CodeWarrior
Computer
Windows (operating system)
CodeWarrior (IDE)
Text Editor
C Compiler
Linker
Other tools
Libraries
21Programming
- Programming is an unnatural act.
- Humans solve problems without knowing how.
- Computers need step-by-step solution (i.e an
algorithm). - Our task
- Learn to create algorithms to solve probs
- Learn the language (for this course, C)
22A Simple Program Printing
- Make a program that prints text on the screen.
- Basic outline of a C program
- Use a library function, printf().
23Functions
- A C program consists of functions.
- Functions are starting points of execution.
- Every C program starts with a function called
'main' - Functions can accept input values, perform tasks,
and possibly return computed values.
24Function Structure
function name
function input
output type
function body start
int main (void) / C instructions here
/ return 0
C instruction
comment
C "period"
output value
function body end
25C Function Libraries
- C comes with many libraries of "ready-made"
functions - Two steps to using them
- Use a "include" statement
- Call the function, I.e., write its name in your
program
26The Printf() function
- Need to include the standard i/o library
- include ltstdio.hgt
- Need to call the function.
- printf("Go Beavers")
- Text inside double quotes called a string.
- printf() prints strings on the output screen.
27A simple program - printing
- include ltstdio.hgt / preprocessor directive /
- int main (void)
-
- printf("Go Beavers") / print some text /
- return 0
28Parts of the program
- Preprocessor
- include ltstdio.hgt
- Include the file named stdio.h as part of this
program. - .
- Comments
- / print some text /
- This is a programmers comment an explanation of
the - meaning of this part of the program. It is
ignored by the - compiler.
29Main Function
- int main (void)
- printf("Go Beavers")
- return 0
-
- All programs in the C language start with the
function - main. A function is a named unit of computation
in the C language. The last statement in main is
always return 0 for this class. - Execution is line by line starting after the
opening brace, , and ends with the closing
brace, .
30Console (Screen) I/O
- I/O means Input/Output
- printf("Go Beavers")
- printf means print formatted to the screen using
certain formatting rules. Characters inside
double quotes are called a string constant or
string literal.