Introduction to Programming Lecture 4. Key Words of C main main if if else else while while do do for for.

Slides:



Advertisements
Similar presentations
ALGEBRA TILES Cancellation. Write the Equation = = -x= x= -1= 1.
Advertisements

For Educational Use Only © Completing the Square Brian Preston Algebra
Revision - Quadratic Equations Solving Quadratic equations by the Quadratic Formula. By I Porter.
Factoring Trinomials of the Type ax2 + bx + c
EXAMPLE 4 Use the discriminant Find the discriminant of the quadratic equation and give the number and type of solutions of the equation. a. x 2 – 8x +
IB HL Adrian Sparrow Factor and remainder theorem.
solution If a quadratic equation is in the form ax 2 + c = 0, no bx term, then it is easier to solve the equation by finding the square roots. Solve.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
CS 1400 Jan 2007 Chapter 4, sections Relational operators Less than< Greater than> Less than or equal= Equal== Not equal!=
Introduction A trinomial of the form that can be written as the square of a binomial is called a perfect square trinomial. We can solve quadratic equations.
1 Interactive Applications (CLI) and Math Interactive Applications Command Line Interfaces The Math Class Example: Solving Quadratic Equations Example:
Solving Quadratic Equations Section 1.3
Copyright © Cengage Learning. All rights reserved.
4.8: Quadratic Formula HW: worksheet
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
EXAMPLE 1 Factor ax 2 + bx + c where c > 0 Factor 5x 2 – 17x + 6. SOLUTION You want 5x 2 – 17x + 6 = (kx + m)(lx + n) where k and l are factors of 5 and.
WARM UP WHAT TO EXPECT FOR THE REST OF THE YEAR 4 May The Discriminant May 29 Chapter Review May 30 Review May 31 Chapter 9 Test June Adding.
6.5 – Solving Equations with Quadratic Techniques.
Quadratic Equations By Dr. Carol A. Marinas. Solving Equations In the previous section, we solved LINEAR equations. This means that the highest exponent.
Using the factoring method, what are the solutions of y = x 2 + 5x + 6.
Algebra B. Factoring an expression is the opposite of multiplying. a ( b + c ) ab + ac Multiplying Factoring Often: When we multiply an expression we.
Chapter 5 Factoring and Algebraic Fractions
EXAMPLE 2 Rationalize denominators of fractions Simplify
Quadratics Solving equations Using “Completing the Square”
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Lecture #6 OPERATORS AND ITS TYPES By Shahid Naseem (Lecturer)
Introduction to Programming Lecture 11. ARRAYS They are special kind of data type They are special kind of data type They are like data structures in.
Introduction Completing the square can be a long process, and not all quadratic expressions can be factored. Rather than completing the square or factoring,
"Give a person a fish and you feed them for a day; teach that person to use the Internet and they won't bother you for weeks.“ --unknown "Treat your password.
Introduction to C Programming Lecture 6. Functions – Call by value – Call by reference Arrays Today's Lecture Includes.
WARM UP WHAT TO EXPECT FOR THE REST OF THE YEAR 4 May The Discriminant May 29 Chapter Review May 30 Review May 31 Chapter 9 Test June Adding.
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
This formula finds the solution(s) for x in any quadratic equation.
Solving Quadratic Formula using the discriminant.
13.1 Introduction to Quadratic Equations
Beginning Algebra 5.7 Solving Equations by Factoring:
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.
Arithmetic Operations (L05) * Arithmetic Operations * Variables * Declaration Statement * Software Development Procedure Problem Solving Using C Dr. Ming.
Warm-Up Exercises EXAMPLE 1 Standardized Test Practice What are the solutions of 3x 2 + 5x = 8? –1 and – A 8 3 B –1 and 8 3 C 1 and – 8 3 D 1 and 8 3 SOLUTION.
Unit 5 Solving Quadratics By Square Roots Method and Completing the Square.
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.
2.2 Solving Quadratic Equations Algebraically Quadratic Equation: Equation written in the form ax 2 + bx + c = 0 ( where a ≠ 0). Zero Product Property:
Deriving the Quadratic Formula
5.6 Quadratic Formula & Discriminant
Warm up Factor the expression.
Chapter 4 Quadratic Equations
Objectives Solve quadratic equations by factoring.
5.3 Factoring Quadratics.
EXAMPLE 2 Rationalize denominators of fractions Simplify
Programming Fundamental
Solve a literal equation
Arithmetic Operator Operation Example + addition x + y
Factoring Special Cases
Introduction to C++ Programming
Introduction to Programming
Programming Funamental slides
Introduction to Programming
Conditional Construct
9-6 The Quadratic Formula and Discriminant
9.3 Solve Quadratics by Completing the Square
Standard Form: Ax + By = C
Example 1 Write an Equation Given Slope and a Point
Tests of Divisibility 1 - All integers can be divided by 1
CS 101 First Exam Review.
Introduction to Programming
Solving Equations by Factoring
3.2 The Remainder Theorem.
Programming Fundamental-1
Presentation transcript:

Introduction to Programming Lecture 4

Key Words of C main main if if else else while while do do for for

x = ; = 6 ; = 6 ; Memory x 6

Memory x = a + b ; ab x

#include <iostream.h> main ( ) { int age1, age2, age3, age4, age5, age6, age7, age8, age9, age10 ; int TotalAge ; int AverageAge ; cout << “ Please enter the age of student 1: “ ; cin >> age1 ; cout << “ Please enter the age of student 2: “ ; cin >> age2 ; : : TotalAge = age1+ age2 + age3+ age4+ age5+age6+ age7+ age8+age9 + age10 ; AverageAge = TotalAge / 10 ; cout<< “The average age of the class is :” << AverageAge ; }

Quadratic Equation In algebra y = ax 2 ax 2 + bx + c In C y = a * x * x + b * x + c

a*b%c +d

a*(b%c) = a*b%c ?

Discriminant b2 - 2a = b*b - 4*a*c /2 *a Incorrect answer Solution = (b*b - 4*a*c) /(2 *a) Correct answer 4c

No expression on the left hand side of the assignment Integer division truncates fractional part Liberal use of brackets/parenthesis

Interesting Problem Given a four-digit integer, separate and print the digits on the screen Given a four-digit integer, separate and print the digits on the screen

Analysis Number = 1234 Number = 1234 Take the remainder of the above number after dividing by 10 Take the remainder of the above number after dividing by 10 Eg 1234 / 10 gives remainder % 10 = 4 Remove last digit Remove last digit –1234/10 = –123(Truncation due to Integer Division) 123 %10 gives %10 gives 3 Remove last digit Remove last digit –123/10 = 12.3 –12 (Truncation due to Integer Division) 12 % 10 gives remainder 2 12 % 10 gives remainder 2 Remove last digit Remove last digit –12/10 = 1.2 –1 (Truncation due to Integer Division) Final digit remains Final digit remains

Code #include #include main ( ) { int number; int digit; cout << “Please enter a 4 digit integer : ”; cin >> number; digit = number %10; cout <<“The digit is: “ << digit << ‘\n’; // first digit; and then << ‘\n’ number = number / 10; digit = number % 10; cout <<“The digit is: “ << digit << ‘\n’; number = number / 10; digit = number % 10; cout <<“The digit is: “ << digit << ‘\n’; number = number / 10; digit = number % 10; cout <<“The digit is: “ << digit; }

Special Character Newline \n