C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

Slides:



Advertisements
Similar presentations
Objective: Students will be able to write and solve two- step equations with one variable!
Advertisements

Types and Arithmetic Operators
CS 6301 Lecture 2: First Program1. CS Topics of this lecture Introduce first program  Explore inputs and outputs of a program Arithmetic using.
Dan Heflin. Well, how do we do this? You take the (4/7), and multiple by 2 to get You take the whole number representation, which is 1 in this.
1 CS150 Introduction to Computer Science 1 Arithmetic Operators.
1 9/20/06CS150 Introduction to Computer Science 1 Review: Exam 1.
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
1 Introduction to Computers and Programming Class 3 Introduction to C Professor Avi Rosenfeld.
1  Ex: Declare a variable to store user’s age: int age; Prompt the user to enter his/her age: printf (“ How old are you? “); Read / scan the entered value.
Basic Input/Output and Variables Ethan Cerami New York
COMPUTER SCIENCE I C++ INTRODUCTION
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
D ATA T YPE. NUMBERS A number is an immutable type – means that changing or updating its value result in a newly allocated object. There are several types.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
PYTHON: PART 2 Catherine and Annie. VARIABLES  That last program was a little simple. You probably want something a little more challenging.  Let’s.
Ch 1.3 – Order of Operations
Input, Output, and Processing
ORDER OF OPERATIONS Back to the Future. Its all Review Order of operations with Integers works the same way for whole numbers, integers, fractions decimals.
Fast Facts II 1 Decimal ____ = 50% = __ %
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
Unit 3, Lesson 3 Math Operations, Assignment Operators, and Arithmetic Operators Mr. Dave Clausen La Cañada High School
Order of Operations Integers. Order of Operations with Integers Be careful when doing the operations to follow the rules of each operation and their sign.
Arithmetic Operations. Review function statement input/output comment #include data type variable identifier constant declaration.
By: Daviana Soberanis. Step 1 Step 1: Decide what your fraction is. Put down the numerator. Press the division sign. Put down the denominator. Press enter.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Chapter 2 Overview of C++. 2 Overview  2.1 Language Elements  2.2 Reserved Words & Identifiers  2.3 Data Types & Declarations  2.4 Input/Output 
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
Continued Four Operations-Division
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
Lecture 5: Expressions and Interactivity Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
ORDER OF OPERATIONS. What is the correct method for solving numerical problems?
Fraction Division: A Whole Number Divided by a Fraction 1  = ? 1515 To get the answer, ask: 1  ? = 1515 How many groups of can be made from 1? 1515.
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 2 September 3, 2009.
By: Tameicka James Addition Subtraction Division Multiplication
Primitive Data Types int is a primitive data type A primitive data type is one that stores only a single piece of data. TypeStorageDescription int 4 bytes+ve.
Variables and Expressions Order of Operations Real Numbers and the Number Line Objective: To solve problems by using the order of operations.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
 Most C programs perform calculations using the C arithmetic operators (Fig. 2.9).  Note the use of various special symbols not used in algebra.  The.
Arithmetic, Functions and Input 9/16/13. Arithmetic Operators C++ has the same arithmetic operators as a calculator: * for multiplication: a * b – Not.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
Arithmetic Operations (L05) * Arithmetic Operations * Variables * Declaration Statement * Software Development Procedure Problem Solving Using C Dr. Ming.
Chapter 02 (Part II) Introduction to C++ Programming.
MATH By: Mr. McTavish. BASIC OPERATIONS  Addition: +  Subtraction: -  Multiplication: *  Division: /  Modulus (division remainder): %
FractionsDecimalsPowers Answer  This is how you add fractions.
Slide Copyright © 2009 Pearson Education, Inc. Welcome to MM 150 Survey of Mathematics.
A standard way to simplify mathematical expressions and equations.
Sig Fig and Conversion Practice
Integers Rules of Operation.
5.2 The Integers.
BASIC ELEMENTS OF A COMPUTER PROGRAM
Data Types and Conversions, Input from the Keyboard
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Quantitative Measurements
A standard way to simplify mathematical expressions and equations.
Algebra Algebra.
SCIENTIFIC NOTATION.
Introduction to C++ Programming
FOUR RULES OF WHOLE NUMBERS
Dividing Decimals by Whole Numbers
Alternate Version of STARTING OUT WITH C++ 4th Edition
A standard way to simplify mathematical expressions and equations.
Lesson 3: Complex Formulas
Primitive Types and Expressions
EXPONENTS… RULES?!?! X ? X 5 2 =.
Ch 1-2 Order of Operations
A standard way to simplify mathematical expressions and equations.
Sig Fig and Conversion Practice
Primitive Data Types and Operators
Introduction to Python
Presentation transcript:

C ONTINUING C++ Precedence Rules, Numeric Types, More Operator Symbols, and Keyboard Input Prompts.

P RESEDENCE R ULES The mathematical order of operations determine to rules for C++ Highest Precedence Parenthesis Exponents Multiplication, Division, Modulus Addition, Subtraction Lowest Precedence

N UMERIC T YPES Variable TypeWhat it does int Takes only the whole number entered, disregards decimals float Takes into account not only the whole number, but also its decimal values If int is used on a variable equaling 10.66, the program sees that variable as the number 10 If float is used on the variable 10.66, the program will see that variable as 10.66

M ORE O PERATOR S YMBOLS OperatorMeaning + Addition - Subtraction * Multiplication / Division % Modulus (remainder from integer division) Be careful with the order of operations!

M ODULUS Modulus is the remainder you obtain from division For Example: 20 / 3 = 6 with a remainder of 2, thus 2 would be the answer for 20 % 3. What would be the answer to 3 * 5 % 6 ? What about to / (3 % 2) ?

CIN cin is a variable that denotes an input stream The operator << is also called an insertion operator, it follows the cin variable and is followed by where you want the variable to go into For Example: Cin >> inches; Note: The program will wait for a value to be inputted after the cin prompt, after you enter what the program is asking for, press enter.