This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: int Exam 2 Review () { // It’s probably gonna be lame. Lauren Bridge Katie Dropiewski Brad Jodoin Predicates; ◊ A function that returns a bool value (true or false) is called a predicate Example; bool sample(double A, double B) { A = A + B * 6; return (A >= 12) or (A<2); } What does it return when A = 2 and B = 6? Example; bool sample(double A, double B) { A = 2 + (6 * 6); return (A >= 12) or (A<2); } What does it return when A = 2 and B = 6? Example; bool sample(double A, double B) { A = 38; return (A >= 12) or (A<2); } What does it return when A = 2 and B = 6? Example; bool sample(double A, double B) { A = 38; return 1 or 0; } What does it return when A = 2 and B = 6? 1 Loops; • Loops provide the means to reach the solution to a problem by successive approximation • 2 Kinds of Loops: • For • While While Loops; int N = 5; int count = 1; int f = 1; while( count<=N ) { f = f * count; count++; } termination condition: N > count initialization loop invariant: f = N! For Loops; for(initialization1, initialization2; continuation; counter) { do something; } For Loops;...
View
Full
Document
This note was uploaded on 10/14/2009 for the course ENGR 101 taught by Professor Ringenberg during the Fall '07 term at University of Michigan.
 Fall '07
 Ringenberg

Click to edit the document details