Comp 150 - Spring 2015 - Steil
General Exam 1 Exam 2 Exam 3 & Final
1. General
2. Exam 1
Week 1
    Steil Cup
    Schaum's book
Decimal- base 10
Binary - base 2
Digital information measurement units
  1. bit - binary digit representing on/off or 1/0
  2. byte - 8 bits, number of bits needed to encode a single character of text
  3. kilobyte - 1000 bytes (or 210 = 1024 bytes)
  4. megabyte - 1000 KB (or 210 = 1024 KB)
  5. gigabyte - 1000 MB (or 210 = 1024 MB)
  6. terabyte - 1000 GB (or 210 = 1024 GB)
Assign Homework
Decimal, Binary, Hex  (Due Wednesday)
Hexadecimal (hex) - base 16
bit & byte
ASCII - American Standard Code for Information Interchange
See ASCII Table in decimal, binary, and hex in Appendix A of Schaum
computer - Electronic machine that operates under the control of stored instructions and can:
  1. accept data (input),
  2. process data arithmetically and logically
  3. produce results (output)
programming - telling the computer in minute detail (typically with a programming language) the sequence of steps required to perform a task.
software development - The entire process involved in creating software and ensuring its future availability. This includes the following:
  1. analysis of the problem the software should solve
  2. designing how the software should be constructed
  3. implementation (programming)
  4. testing the software
  5. deploying the software
  6. maintaining the software and fixing bugs
Hardware vs. software
Hardware - The physical parts of a computer that you can see and touch
Software - The programs that control the hardware
data vs programs (programs are instructions run by the processor, data are values used by the programs, they are both just bytes)        
Algorithm (Defined by Google) - a process or set of rules to be followed in calculations or other problem-solving operations, esp. by a computer.
Primitive - A task that one can perform in an algorithm with no further explanation
Assign Homework
Algorithm (ways To Represent)
  1. Verbal
  2. Textual
  3. Flow chart
  4. Program
Fundamental Theorem of Structured Programming
       sequence - one process after another
       choice - one way or two way choice
       repetition - pretest or post test loop
flow chart control structures - a grouping of flow chart logic with one way in and one way out
examples: a process, one way choice, two way choice, prest loop, post test loop
Finding remainders with % (the modules operator)
Structured vs. Unstructured flowcharts
intro to overflow
count to 10
Week 2
No Class, MLK day
Review "what is it #1 & #2 flowcharts"
Algorithm/Flowchart examples
Overflow introduction:
Algorithm Constructs: 1 way choice, 2 way choice, pretest loop, post-test loop
See Notes on Easel
increment, decrement
Assign Homework
What is it 1 (Due Friday)
What is it 2  (Due Friday)
More Flow chart examples
Assign Homework
What is it 3  (Due Monday)
What is it 4  (Due Monday)
Week 3
Decimal To Binary Flowchart using Overflow
Assign Homework
Booting a computer (bootstrapping)
BIOS (Basic Input Output System)
Dream Spark - MS Software
data vs programs (programs are instructions run by the processor, data are values used by the programs, they are both just bytes)
programming languages & generations
Compile - translate to machine language
Compiler - program that compiles
syntax - how symbols are combined to form valid expressions
semantics - meaning of the symbols that form an expression
language - symbols with semantic meaning and syntax used to write instructions for the computer
Language Generations
   1st - Machine   (.exe files in windows)
   2nd - Assembly
   3rd - High Level  (c++ is here)
   4th - Very High Level   
 Intro to C++ syntax
History of C++
  1. 1950s - Early programming languages where difficult to use, and maintaining large programs was becomming increasingly difficult
  2. 1960s - Martin Richards, working the University of Cambridge, developed a structured programming language called BCPL (Basic Combined Programming Language). Ken Thompson at Bell Labs created B, a modified version of BCPL
  3. 1970s - Dennis Ritchie at Bell Labs improved on the B language and called his creation C. It is one of the most widely used programming lanugages of all time
  4. 1980s - A new paradigm was being adopted called Object-Oriented Programming (OOP) which sought to reduce the cost of designing, implementing, debugging, and modifying large, complex programs. Bjarne Stroustrup at Bell Labs created C++ by adding OOP constructs to the C programming language. C++ is one of the most popular programming languages in the world
  5. Many programming languages (Java, C#, JavaScript, Python) are very similar to C++, so once you learn C++ it is not difficult to learn other programming languages
IDE - Integrated Development Environment
   Compiler, code editor, Debugger, Help system
using namespace std;
void main() {}
literal - a number such as 45 or a word such as "Bob" that is not a variable
// - begins a comment line in c++
# - lines that begin with this are instructions to the compiler (aka, compiler directive)
brief introduction to variables
writing to output stream... cout << 
reading from input stream... cin >>
>> - stream extraction operator
<< - stream insertion operator
cascading << 
Read chapters 1 from Schaum's (Due Monday)
Week 4
declaring variables
data types
short - 2 bytes, no decimals
int - 4 bytes, no decimals
float - 4 bytes, with decimals
double - 8 bytes, with decimals
bool - 1 byte, true or false
Integer vs. Floating point Division
integer division - decimals are lost
% - modulas operator - used to find remainders of integer division
cin >>  - reads until white space
   example - 1 2 3 4 5 - entered into the input stream
cascading >> 
Assign Homework
Read chapter 2 from Schaum's (Skip 2.3) Due Wednesday
Type conversions
Arithmetic operators
increment & decrement
Round-off error
conditional statements - if, if-else, if-else-if control structures
if  - one way choice
if else  - two way choice
use of {} with conditions
escape sequences  "\n, \r, \t, \a, \\, \b" _______________
logical and &&
logical or ||
use ! (aka not) to negate a boolean expression
Assign Homework
Read Schaum's Chapter 3.1-3.8 (Due Monday)
Valid Date C++ Program   (Due Wednesday)
Week 5
when can nested if-else structures be turned into if-else-if structures
accidental use of a ";" at the end of an if statement
Wednesday Review for Exam 1
Friday Exam 1
3. Exam 2
Week 6
  1. Computer Hardware
  1. Booting a computer (bootstrapping)
  2. BIOS (Basic Input Output System)
  3. Operating System
  4. Instruction Cycle
  • Fetch
  • Decode
  • Execute
"I will not talk in class" example
#include <iomanip> 
++  increment operator
--  decrement operator
Assign Homework
Is Prime (Due Monday)
Read chapters 4 from Schaum
nested loops
do while
determinate(counted) vs indeterminate loops
data validation loops
Controlling the width of the next item to be displayed
  • cout << setw(4) << value;
Assign Homework
Read chapters 4 from Schaum
Week 7
4 parts to every loop
1. Initialize the test condition
2. Test the condition
3. Body of the loop.... Do something useful
4. Change the test condition
for loops
Lab day for makeup work
Assign console drawing project for extra credit
 More on nested loops and drawing ascii rectangles, checkerboards and checkerboards with frames.
Assign Project
Credit Card Project (Due Friday)
Week 8
Falling Object (example of setw and precision)
Controlling decimal number output
cout.setf(ios::fixed) makes all floating-point numbers display their decimal points (no scientific notation)
cout.precision(places) rounds the decimal places to a given number. When the precision that is set causes some digits to not be shown, those that are displayed are rounded.
Falling Object in C#
Week 9
Introduction to functions
examples of built in functions
  • sqrt & other math functions
void - verb names
non-void - noun names  - must return a value
function signature (aka. declaration/definition) vs function call
arguments and parameters
  • parameter - part of the function's signature
  • argument - part of the function call
non-void functions can only return one value but can have multiple return statements
//function aka  method, routine, sub-routine, sub
Why use functions?
  1. documentation
  2. modularization aka componentization  aka hiding the mess
  3. reuse - saves time and is more reliable
  1. reduces complexity: Functions can simplify a program greatly and make it easier to understand what is happening, and program tend to be shorter
Assign Homework
Read Chapter 5 sections 1-10
Prime Factors C++ (Due Tuesday)
Boolean functions
c++ return statement
by value vs. by reference
By Value:
  • By default, arguments are passed by value to a function which means a copy is made of the argument
  • Any changes made to a parameter are only changing the copy, not the actual argument
  • It's like handing someone a photocopy of a paper you wrote; any changes the person makes to the photocopy doesn't change the original paper
By Reference:
  • This means the parameter is just another name for the argument
  • Therefore any changes made to the reference parameter will also change the argument (modifying x will change a, and modifying y will change b)
  • It's like handing someone the original paper you wrote; any changes the person makes to the original will affect the original.
  • Uses an ampersand (&)
only variables can be passed to a function that receives arguments by reference (literals cannot be passed by ref)
Work examples from Schaum's book chapter 5
Assign Homework
Work problems 5.21, 5.22, 5.24 and 5.25 from Schaum's book.  Use Boolean return values rather than integers for 5.21 and 5.22. (Due Wednesday)
Week 10
Wednesday Review for Exam 2
Friday Exam 2
4. Exam 3 & Final
Week 11
Week 12
Week 13
Week 14
Week 15
Wednesday Review for Exam 3 & Final
Friday Exam 3