Midterm Review.

Slides:



Advertisements
Similar presentations
Chapter 4 Computation Bjarne Stroustrup
Advertisements

Selection The Switch Statement 2/16/11. grade = 'P'; switch (grade){ case 'A': cout
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
1 9/15/06CS150 Introduction to Computer Science 1 Combined Assignments, Relational Operators, and the If Statement.
1 9/20/06CS150 Introduction to Computer Science 1 Review: Exam 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
If Statements. COMP104 If / Slide 2 Three Program Structures * Sequence - executable statements which the computer processes in the given order * Choice.
Copyright © 2012 Pearson Education, Inc. Chapter 4: Making Decisions.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
1 Midterm Review COMP 102. Tips l Eat a light meal before the exam l NO electronic devices (including calculators, dictionaries, phones, pagers, etc.)
The If/Else Statement, Boolean Flags, and Menus Page 180
Chapter 4 Making Decisions
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control if-else and switch statements.
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Announcements 1st homework is due on July 16, next Wednesday, at 19:00 Submit to SUCourse About the homework: Add the following at the end of your code.
More on Input Output Input Stream : A sequence of characters from an input device (like the keyboard) to the computer (the program running). Output Stream.
CS31: Introduction to Computer Science I Discussion 1A 4/9/2010 Sungwon Yang
Copyright © 2012 Pearson Education, Inc. Chapter 4: Making Decisions.
CPS120: Introduction to Computer Science
Decision II. CSCE 1062 Outline  Boolean expressions  switch statement (section 4.8)
Chapter 3:Decision Structures.  3.1 The if Statement  3.2 The if-else Statement  3.3 The if-else-if Statement  3.4 Nested if Statements  3.5 Logical.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Making Decisions. 4.1 Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than.
CompSci 100E 2.1 Java Basics - Expressions  Literals  A literal is a constant value also called a self-defining term  Possibilities: o Object: null,
Chapter 4 Making Decision Csc 125 C++ programming language Fall 2005.
Chapter 05 (Part III) Control Statements: Part II.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Making Decisions.
4.1 Object Operations operators Dot (. ) and new operate on objects The assignment operator ( = ) Arithmetic operators + - * / % Unary operators.
Refer to Ivor Horton’s Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Choices and Decisions if statement if-else statement Relational.
1 09/15/04CS150 Introduction to Computer Science 1 Life is Full of Alternatives Part 2.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 4: Making Decisions.
Chapter Making Decisions 4. Relational Operators 4.1.
CHAPTER 5 MAKING DECISION Hidayah Elias BFC2042 – Computer Programming.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 4 Making Decisions.
COMP Loop Statements Yi Hong May 21, 2015.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 4: Making Decisions 1.
Lecture 6 – Selection FTMK, UTeM – Sem /2014.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 15, 2004 Lecture Number: 11.
Chapter 3 Selection Statements
Review 1.
Chapter 3 Control Statements
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
CMPT 201.
CMPT 238 Data Structures C++ Review
CMSC 202 Lesson 2 C++ Primer.
Control Structures Combine individual statements into a single logical unit with one entry point and one exit point. Used to regulate the flow of execution.
Decisions Chapter 4.
Chapter 4: Making Decisions.
CMPT 201 if-else statement
Computing Fundamentals
Chapter 4: Making Decisions.
Chapter 4: Making Decisions.
Lecture 2-3 C++ Basic Constructs
I Know What I Want to Do – Now What??
Midterm Exam Preperation
Introduction to C++ Programming
Announcements General rules about homeworks
Announcements General rules about homeworks
CSE 1020:Control Structure
Summary Two basic concepts: variables and assignments Basic types:
Chapter 4: Control Structures I (Selection)
Chapter 2: Introduction to C++.
Announcements General rules about homeworks
CSS 161: Fundamentals of Computing
Presentation transcript:

Midterm Review

First Midterm Exam Friday, Oct 6th Closed book But.. you may bring a cheat sheet! One side of an A4-sized paper Partial access to computers

Part II (paper or computer based) Part I (paper based) Multiple choices Write the output of a program Part II (paper or computer based) Programming Visual Studio only You shouldn’t use the network

Variables a place to hold a number or data of other types Variable names Start with a letter or the underscore Remaining can be letters, numbers or underscore x x1 3X _abc %change data-1 PROG.CPP Big_Bonus C++ is case-sensitive rate RATE Rate

The output function cout c(C++ language)out(output) c(C++ language)in(input) cout<<whatever data you want to output; cout<<“Welcome to CMPT102!”; << represents the flow of the data.

Input Function cin cout: output to screen cin: input from keyboard cout<<whatever you want to output; cin>>variable_name; cin>>variable1>>variable2; Or cin>>variable1; cin>>variable2;

http://software. intel http://software.intel.com/en-us/articles/size-of-long-integer-type-on-different-architecture-and-os

The char Type Short for character Any single character from the keyboard a letter, a digit, or punctuation mark int number; char letter; int number = 5; char letter = ‘a’; char letter = ‘A’;

The Class string #include <string> Concatenation char letter; string message; char letter = ‘a’; string message = “hello”; Concatenation string firstName = “Chuck”; string lastName = “Norris”; string name = firstName + lastName; //string name = firstName + “ “ + lastName;

getline() To read the whole line of input into a string string name; getline(cin, name);

The bool Type Boolean Two values bool flag; bool isPrime = false; True

Arithmetic Operators +, -, *, / int / int -> int double / int -> double 10/3, 5/2, 11/3

Modulus % 17 % 5 = 2 23 % 2 = ? 20 % 3 = ? How to determine if a number is even/odd?

Syntax for if-else if (condition) Yes_Statement else No_Statement Chooses between two alternative actions

The And Operator If score is greater than 0 and less than 100... (score > 0) && (score < 100) is true only if both are true

The Or Operator (score1 >= 60) || (score2 >= 60) is true if one or both are true

The Not Operator !(score > 60) is equivalent to score <= 60

Nested Statements

Multiway if-else syntax if (condition_1) Action_1; else if (condition_2) Action_2; ... else if (condition_N) Action_N; else Action_For_All_Other_Cases;

The Conditional Operator Can use to create short if/else statements Format: expr ? expr : expr; x<0 ? y=10 : z=20; First Expression: Expression to be tested 2nd Expression: Executes if first expression is true 3rd Expression: Executes if the first expression is false

Type Casting static_cast<Type>(Value) double -> int static_cast<int>(9.2) static_cast<int>(number)

switch Statement Syntax switch (Controlling_Expression) { case result_1: Statement_Sequence_1; break; case result_2: ... case result_n: Statement_Sequence_n; default: Default_Statement_Sequence; }

Syntax of the while Statement while (Boolean_Expression) { Statement_1; // body Statement_2; // iteration ... } Statement;

The do-while Statement { Statement_1; Statement_2; ... } while (Boolean_Expression); Statement; while (Boolean_Expression);

Announcements Homework 3 is out No class on Tuesday, Oct 10 Due on Friday, Oct 13 No class on Tuesday, Oct 10 Follows a Monday schedule