Copyright © 2004-2012 Curt Hill The C++ IF Statement The most important decision statement Part 1.

Slides:



Advertisements
Similar presentations
Solving Quadratic Equations Lesson 9-3
Advertisements

Solving Quadratic Equations Algebraically Lesson 2.2.
The Discriminant Check for Understanding – Given a quadratic equation use the discriminant to determine the nature of the roots.
Lesson 1-6 Solving Quadratic Equations. Objective:
Essential Question: What are some things the discriminate is used for?
The Quadratic Formula..
Chapter 4 – Polynomials and Rational Functions
ax² + bx + c = 0 x² + 8x + 16 = f(x) To make the chart, you simply take any number and plug it in for x in the equation and the value you get is the y.
Graph quadratic equations. Complete the square to graph quadratic equations. Use the Vertex Formula to graph quadratic equations. Solve a Quadratic Equation.
Solving Quadratic Equations Section 1.3
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 1 Equations and Inequalities Copyright © 2013, 2009, 2005 Pearson Education, Inc.
Copyright © Cengage Learning. All rights reserved.
Sec 5.6 Quadratic Formula & Discriminant Quadratic Formula (Yes, it’s the one with the song!) If ax 2 + bx + c = 0 and a ≠ 0, then the solutions (roots)
Objectives: To solve quadratic equations using the Quadratic Formula. To determine the number of solutions by using the discriminant.
OBJECTIVES © 2010 Pearson Education, Inc. All rights reserved 1 Quadratic Equations Solve a quadratic equation by factoring. Solve a quadratic equation.
Section 10.5 – Page 506 Objectives Use the quadratic formula to find solutions to quadratic equations. Use the quadratic formula to find the zeros of a.
HAWKES LEARNING SYSTEMS Students Matter. Success Counts. Copyright © 2013 by Hawkes Learning Systems/Quant Systems, Inc. All rights reserved. Section 15.3.
Using the factoring method, what are the solutions of y = x 2 + 5x + 6.
5.6 Quadratic Equations and Complex Numbers
Aim: The Discriminant Course: Adv. Alg, & Trig. Aim: What is the discriminant and how does it help us determine the roots of a parabola? Do Now: Graph.
With Professor Owl Created by Robbie Smith. Quadratic Term: ax² Linear Term: bx Constant Term: c In order to have a solution, the line or parabola must.
Solving Quadratic Equations Using Completing the Square and the Quadratic Formula.
Goals: To solve quadratic equations by using the Quadratic Formula.
Module :MA0001NP Foundation Mathematics Lecture Week 9.
Solving Quadratic Equations. Solving by Factoring.
1 Copyright © 2015, 2011, 2007 Pearson Education, Inc. Chapter 8-1 Quadratic Functions Chapter 8.
3.8 Warm Up Write the function in vertex form (by completing the square) and identify the vertex. a. y = x² + 14x + 11 b. y = 2x² + 4x – 5 c. y = x² -
Chapter 10 Section 3 Solving Quadratic Equations by the Quadratic Formula.
SOLVING QUADRATIC EQUATIONS BY COMPLETING THE SQUARE BECAUSE GRAPHING IS SOMETIMES INACCURATE, ALGEBRA CAN BE USED TO FIND EXACT SOLUTIONS. ONE OF THOSE.
The Quadratic Formula Students will be able to solve quadratic equations by using the quadratic formula.
CPM Section 9.4A Quadratic Formula. Thus far we have considered two methods for solving quadratic function- factoring and using the square root property.
Copyright Curt Hill The C/C++ switch Statement A multi-path decision statement.
Given a quadratic equation use the discriminant to determine the nature of the roots.
4.2 Quadratic Functions Objective: Solve quadratic equations. Use the discriminant to describe the roots of a quadratic equation.
Getting Started The objective is to be able to solve any quadratic equation by using the quadratic formula. Quadratic Equation - An equation in x that.
Chapter 4: Polynomial and Rational Functions. 4-2 Quadratic Equations For a quadratic equation in the form ax 2 + bx + c = 0 The quadratic Formula is.
ALGEBRA 2 – CHAPTER 5 QUADRATICS. 5-2 PROPERTIES OF PARABOLAS.
Copyright Curt Hill The Assignment Operator and Statement The Most Common Statement you will use.
Warm-Up Solve each equation by factoring. 1) x x + 36 = 02) 2x 2 + 5x = 12.
Copyright © Curt Hill The Assignment Operator and Statement The Most Common Statement you will use.
Solving Quadratic Equations by Using the Quadratic Formula (9-5) Objective: Solve quadratic equations by using the Quadratic Formula. Use the discriminant.
Warm Up  1.) Write 15x 2 + 6x = 14x in standard form. (ax 2 + bx + c = 0)  2.) Evaluate b 2 – 4ac when a = 3, b = -6, and c = 5.
Lesson 6.5: The Quadratic Formula and the Discriminant, pg. 313 Goals: To solve quadratic equations by using the Quadratic Formula. To use the discriminant.
Solving Quadratic Equations Quadratic Formula Medina (Revised 2/26/14 ep)1.
Created by Judy L. McDaniel. Be sure to write a quadratic equation in before using most methods for solving. (not necessarily for the Square Root Prop.)
Chapter 4 Quadratic Equations
College Algebra B Unit 8 Seminar Kojis J. Brown Square Root Property Completing the Square Quadratic Equation Discriminant.
1.2 Quadratic Equations. Quadratic Equation A quadratic equation is an equation equivalent to one of the form ax² + bx + c = 0 where a, b, and c are real.
Copyright © Curt Hill The C++ IF Statement More important details More fun Part 3.
Solving Quadratic Equations by the Quadratic Formula.
Section 2.5 – Quadratic Equations
Chapter 4 Quadratic Equations
More important details More fun Part 3
Solving quadratics methods
Nature of Roots of a Quadratic Equation
The Discriminant Check for Understanding –
CHAPTER R: Basic Concepts of Algebra
Worksheet Key 9 11/14/2018 8:58 PM Quadratic Formula.
The C++ IF Statement Part 2 Copyright © Curt Hill
2.2: Solving Equations Through Various Methods
The Quadratic Formula.
9-6 The Quadratic Formula and Discriminant
The most important decision statement
Quadratic Formula & the Discriminant
Quadratic Equations and Functions
Review: Simplify.
Notes Over 9.1 Finding Square Roots of Numbers
Chapter 8 Quadratic Functions.
The Discriminant Check for Understanding –
Chapter 3 Quadratic Equations
Presentation transcript:

Copyright © Curt Hill The C++ IF Statement The most important decision statement Part 1

Copyright © Curt Hill Flow of Control in C/C++/Java Recall the flow statements in C: –Decisions If Switch Case –Loops for while do Break Here we consider the if

Copyright © Curt Hill Why? There are too many times when we need a conditional statement –One statement is executed in one set of circumstances and another otherwise We also want our programs to be robust –Unlikely to abnormally terminate regardless of what the user does

Copyright © Curt Hill Example Suppose the following statement: avg = total/count; If count is zero the program will abnormally terminate with a divide by zero exception The solution is nesting this in an if: if(count > 0) avg = total/count;

Copyright © Curt Hill Example Revisited The basic form is: if (cond) statement; The if is a reserved word The parentheses are required –They show the limit of the condition Only a single statement is allowed

Copyright © Curt Hill A Condition Any expression Usually of type boolean Usually a comparison May include boolean methods May include boolean operators Other possibilities also exist

Copyright © Curt Hill Comparisons A comparison has the form: expr op expr Expr may be any expression –Involves constants, variables, operators –Produces a value The comparison operators include: – >= <= == != Do not confuse = with == The precedence of comparisons is lower than any arithmetic and higher than assignment

Copyright © Curt Hill Example comparisions: OK: if(a b*2) If(a*b<c-4*d) // Not so simple Not so good if (a = b) Even worse if(a<b<c)

Copyright © Curt Hill Mixed mode again The same mixed mode rules apply to comparisons as arithmetic Comparing an integer to a double automatically casts the integer as a double for the purposes of the comparisons The arithmetic may generate casts The comparisons may generate additional ones

Copyright © Curt Hill Example Now that the minimal basics are complete, lets look at an example program We will write a program that evaluates the quadratic formula to find the zeros of a quadratic equation

Copyright © Curt Hill Quadratic Formula For those of you who forgot Any equation that may be put into this form: ax 2 + bx + c = 0 has the following solution:

Copyright © Curt Hill Quadratics Quadratics take the form of a parabola This parabola may point up or down It may have zero, one or two solutions

Copyright © Curt Hill The Discriminant The key item here is the expression under the radical b 2 – 4ac which determines how many solutions If it is negative, no real solution If it is zero, one real solution If it is positive, two real solutions Thus it is the focus of the ifs

Copyright © Curt Hill The Solution The C++ program needs three distinct paths Each path is chosen based on the value of the discriminant Only one of these evaluates the square root Lets write the program!