UMBC CMSC 104 – Section 01, Fall 2016

Slides:



Advertisements
Similar presentations
CMSC 104, Version 9/011 Arithmetic Operators Topics Arithmetic Operators Operator Precedence Evaluating Arithmetic Expressions In-class Project Incremental.
Advertisements

CS 117 Spring 2002 Review for Exam 2 March 6, 2002 open book, 1 page of notes.
CMSC 104, Version 8/061L22Arrays1.ppt Arrays, Part 1 of 2 Topics Definition of a Data Structure Definition of an Array Array Declaration, Initialization,
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
CMSC 104, Version 8/061L11Relational&LogicalOps.ppt Relational and Logical Operators Topics Relational Operators and Expressions The if Statement The if-else.
CMCS 104, Lecture 25 - REVIEW1 Review l Read textbook chapters l Read Lectures l General Programming Tips: ouse Top-Down Design ouse Incremental.
CMSC 104, Version 9/011 Relational and Logical Operators Topics Relational Operators and Expressions The if Statement The if-else Statement Nesting of.
Final Review1 Final Exam l Final Exam: Thursday December 15, 2005 at 8:30 pm in room MP-008, the regular classroom. If you can not make it to the exam.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
CMSC201 Computer Science I for Majors Lecture 05 – Comparison Operators and Boolean (Logical) Operators Prof. Katherine Gibson Prof. Jeremy.
CMSC201 Computer Science I for Majors Lecture 03 – Operators
UMBC CMSC 104 – Section 01, Fall 2016
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
Lecture 7: Repeating a Known Number of Times
Variables and Arithmetic Operators in JavaScript
JavaScript: Control Statements I
CMSC201 Computer Science I for Majors Lecture 03 – Operators
2008/10/22: Lecture 12 CMSC 104, Section 0101 John Y. Park
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
2011/11/20: Lecture 15 CMSC 104, Section 4 Richard Chang
The C “switch” Statement
Relational & Logical Operators
Arrays, Part 1 of 2 Topics Definition of a Data Structure
2008/10/27: Lecture 13 CMSC 104, Section 0101 John Y. Park
The C “switch” Statement
Arithmetic Operators in C
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
Relational and Logical Operators
Final Exam Final Exam: Thursday Dec 13th, 2001 at 8:30 pm in SS-111, the regular classroom.
Functions I Creating a programming with small logical units of code.
2008/10/22: Lecture 12 CMSC 104, Section 0101 John Y. Park
Relational and Logical Operators
Review for Final Exam.
Arithmetic Operators in C
Chapter 4 - Program Control
The switch Statement Topics Multiple Selection switch Statement
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Arrays, Part 1 of 2 Topics Definition of a Data Structure
UMBC CMSC 104 – Section 01, Fall 2016
Homework Any Questions?.
Relational & Logical Operators, if and switch Statements
Relational and Logical Operators
2008/10/27: Lecture 13 CMSC 104, Section 0101 John Y. Park
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Review for Final Exam.
Assignment Operators Topics Increment and Decrement Operators
Functions, Part 1 of 3 Topics Using Predefined Functions
More Loops Topics Counter-Controlled (Definite) Repetition
1-6 Midterm Review.
Relational and Logical Operators
Arithmetic Operators Topics Arithmetic Operators Operator Precedence
More Loops Topics Counter-Controlled (Definite) Repetition
More Loops Topics Relational Operators Logical Operators for Loops.
More Loops Topics Counter-Controlled (Definite) Repetition
Relational and Logical Operators
More Loops Topics Counter-Controlled (Definite) Repetition
Chap 7. Advanced Control Statements in Java
Assignment Operators Topics Increment and Decrement Operators
Assignment Operators Topics Increment and Decrement Operators
Relational and Logical Operators
Functions, Part 1 of 3 Topics Using Predefined Functions
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Arrays, Part 1 of 2 Topics Definition of a Data Structure
Functions I Creating a programming with small logical units of code.
More Loops Topics Counter-Controlled (Definite) Repetition
Assignment Operators Topics Increment and Decrement Operators
More Loops Topics Counter-Controlled (Definite) Repetition
Presentation transcript:

UMBC CMSC 104 – Section 01, Fall 2016 Exam 2 Review

Notes & Announcements Project 8 due… now! Will review in a moment Today is final day to fill out course evals Look for email from StudentCourseEvaluations@umbc.edu

Final Exam The final exam is scheduled for: Thursday, December 15th 6:00 – 8:00 PM Engineering 122 (here) The exam will be on paper – bring a pencil! You may bring a calculator. You probably won’t need it. NO PHONES OR COMPUTER USAGE ALLOWED Bring your UMBC ID!

Requesting Feedback Did you prefer the course website over Blackboard? Why? Would you have preferred less projects and another exam? Why? Would you have preferred more in-class labs, assuming they didn’t count for EC? Other comments?

Exam 2 Review

Overview If it’s in the slides, it’s fair game Broad Concepts Arithmetic Ops (+, -, *, /, %) Assignment Ops (++, --, +=, -=, etc) Relational Ops & Selection Statements (if, else if, else) For loops and While loops Switch Statements Functions Arrays Searching & Sorting Algorithms Pointers

Arithmetic Operators in C Name Operator Example Addition + num1 + num2 Subtraction - initial – spent Multiplication * fathoms * 6 Division / sum / count Modulus % m % n

Rules of Operator Precedence Operator(s) Precedence & Associativity ( ) Evaluated first. If nested (embedded), innermost first. If on the same level, left to right. * / % Evaluated second. If there are several, evaluated left to right. + - Evaluated third. If there are several, evaluated left to right. = Evaluated last, right to left.

Increment and Decrement Operators The increment operator ++ The decrement operator -- Precedence: lower than (), but higher than * / and % Associativity: right to left Increment and decrement operators can only be applied to variables, not to constants or expressions

Assignment Operators = += -= *= /= %= Statement Equivalent Statement = += -= *= /= %= Statement Equivalent Statement a = a + 2 ; a += 2 ; a = a - 3 ; a -= 3 ; a = a * 2 ; a *= 2 ; a = a / 4 ; a /= 4 ; a = a % 2 ; a %= 2 ; b = b + ( c + 2 ) ; b += c + 2 ; d = d * ( e - 5 ) ; d *= e - 5 ;

Relational Operators Relational expressions evaluate to the integer < less than > greater than <= less than or equal to >= greater than or equal to == is equal to != is not equal to Relational expressions evaluate to the integer values 1 (true) or 0 (false). All of these operators are called binary operators because they take two expressions as operands.

Logical Operators So far we have seen only simple conditions. if ( count > 10 ) . . . Sometimes we need to test multiple conditions in order to make a decision. Logical operators are used for combining simple conditions to make complex conditions. && is AND if ( x > 5 && y < 6 ) || is OR if ( z == 0 || x > 10 ) ! is NOT if (! (bob > 42) )

Nesting of if-else Statements if ( condition1 ) { statement(s) } else if ( condition2 ) . . . /* more else clauses may be here */ else statement(s) /* the default case */

The while Repetition Structure while ( condition ) { statement(s) } The braces are not required if the loop body contains only a single statement. However, they are a good idea and are required by the 104 C Coding Standards.

The for Loop Repetition Structure The for loop handles details of the counter-controlled loop “automatically”. The initialization of the loop control variable, the termination condition test, and control variable modification are handled in the for loop structure. for ( i = 1; i < 101; i = i + 1) { initialization modification } test

The switch Multiple-Selection Structure switch ( integer expression ) { case constant1 : statement(s) break ; case constant2 : . . . default: }

Examining PrintMessage #include <stdio.h> void PrintMessage ( void ) ; function prototype int main ( ) { PrintMessage ( ) ; function call return 0 ; } void PrintMessage ( void ) function header printf (“A message for you:\n\n”) ; function printf (“Have a nice day!\n”) ; body } function definition

Array Declaration and Initialization int numbers[5] ; The name of this array is “numbers”. This declaration sets aside a chunk of memory that is big enough to hold 5 integers. It does not necessarily initialize those memory locations to 0 or any other value. They may contain garbage. Initializing an array may be done with an array initializer, as in : int numbers[5] = { 5, 2, 6, 9, 3 } ; numbers 5 2 6 9 3

Accessing Array Elements Each element in an array has a subscript (index) associated with it. Subscripts are integers and always begin at zero. Values of individual elements can be accessed by indexing into the array. For example, printf(“The third element = %d.\n”, numbers[2]); would give the output The third element = 6. numbers 5 2 6 9 3 0 1 2 3 4

Don’t Forget… Searching & Sorting Pointers Searching Algorithms Sorting Algorithms Efficiency Pointers Definition of a pointer Types of pointers Uses for pointers

Questions?