CMP 131 Introduction to Computer Programming

Slides:



Advertisements
Similar presentations
Division & Divisibility. a divides b if a is not zero there is a m such that a.m = b a is a factor of b b is a multiple of a a|b Division.
Advertisements

Mod arithmetic.
Selection Process If … then … else.... Condition Process 2 Process 1 Y.
Pascal Syntax. What you have learnt so far writeln() and write(); readln() and read(); variables (integers, strings, character) manipulation of variables.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 3, Lecture 2.
Announcements Quiz 1 Next Week. int : Integer Range of Typically -32,768 to 32,767 (machine and compiler dependent) float : Real Number (i.e., integer.
Assembly Language Programming. CPU The CPU contains a Control Unit, Arithmetic Logic Unit (ALU) and a small number of memory locations called Registers.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
7/14/ :41 AM6.4 - Dividing Polynomials (Long Division)1 Polynomial Division SECTION 6.4 LONG DIVISION and Synthetic Division.
How do we divide decimals?
1 Section 1.9 Division of Algebraic Expressions. 2 I. Dividing Monomials Divide the numerical coefficients; then divide the literal numbers (variables)
1 The CONST definition CONST Pi = , City = ‘New York’; Constant identifiers are used when you do not want the value of an identifier to change why.
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Lecture 13 Midterm overview When you know a thing, to hold that you know it, and when you do not know a thing, to allow that you do not know it: this is.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 3A Integral Data (Concepts)
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
When dividing a decimal by a whole number, place the decimal point in the quotient directly above the decimal point in the dividend. Then divide as you.
+ Division Objective: I can divide multi-digit whole numbers by whole numbers divisors with and without remainders.
Decimal Division. To divide a decimal by a whole number move the decimal point straight up and then divide as usual.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.
INFORMATION TECHNOLOGY CSEC CXC 10/25/ PASCAL is a programming language named after the 17th century mathematician Blaise Pascal. Pascal provides.
1 Week 2: Variables and Assignment Statements READING: 1.4 – 1.6 EECS Introduction to Computing for the Physical Sciences.
1 CSC 110AA Introduction to Computer Science for Majors - Spring 2003 Class 5 Chapter 2 Type Casting, Characters, and Arithmetic Operators.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 6, Lecture 1 (Monday)
Arithmetic in Pascal A Short Glance We will learn the followings in this chapter Arithmetic operators Order of precedence Assignment statements Arithmetic.
Pascal CourseWinter 2010/111. Introduction Imperative and procedural programming language Designed: 1968/9 Published: 1970 Static and strong typing.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 1 (Monday)
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Data Types Declarations Expressions Data storage C++ Basics.
Programming with Visual C++: Concepts and Projects Chapter 3A: Integral Data (Concepts)
Pascal Programming Today Chapter 11 1 Chapter 11.
1 STRINGS String data type Basic operations on strings String functions String procedures.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Arithmetic OperatorOperationExample +additionx + y -subtractionx - y *multiplicationx * y /divisionx / y Mathematical FormulaC Expressions b 2 – 4acb *
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
Doing math In java.
Section 5.5. Dividing a Polynomial by a Polynomial The objective is to be able to divide a polynomial by a polynomial by using long division. Dividend.
1 More on Readln:numerical values Note: ENTER key counts sends a carriage return and a line feed to the computer definition: “white space”: space, tab,
DIVISION. Standards G4.1M.C2.PO4A. Use multiple strategies to divide whole numbers using 4-digit dividends and divisors from 1 to 12 with remainders.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 5, Lecture 2 (Tuesday)
My Book of Divisibility. THE 2’s Example: 30, 42, 24, 76, 98, Must be an even number Number must end in a 0, 2, 4, 6, or 8.
Review. Problem 1 What is the output of the following piece of code void increment(int x) { x++; } int main() { int y = 10; increment(y); cout
Basic Math skills Lesson 6: Dividing Whole Numbers p
Input and Output Output Prompt: –A message displayed to the user indicating what they are to enter. Should be clear and exact on what you want. write:
Topic VII: Polynomial Functions Polynomial Operations.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
Chapter 2 – part b Brent M. Dingle Texas A&M University
Assignment 15: 11.5 WB Pg. 153 #2 – 20 even
Mathematics Introduction & Formulas. Number System Number System is a writing system for expressing numbers.
The CONST definition CONST Pi = , City = ‘New York’;
More about Polynomials
Dividing Polynomials Algebra
Pascal Winter 2010/ Course.
Assignment statement and Arithmetic operation 2
A Very Brief Overview of Pascal
Arithmetic Operator Operation Example + addition x + y
Examples of Primitive Values
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
kbkjlj/m/lkiubljj'pl;
#1 Dividing by a Whole Number
More Maths Programming Guides.
Decimal Division.
Modular Arithmetic.
Division and Modulo 15 Q A = Dividend B = Divisor Q = Quotient = A/B
Computer Science 1 For..do loop Dry Run Take notes on the For loop
Warm-up: Dry Run DIV / MOD 2nd If Then Program
Dividing Integers ÷ = + ÷ = + ÷ = + ÷ =.
COMPUTING.
Presentation transcript:

CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 4, Lab

Brief Review Expressions Pascal Data Types Real Ordinal Data Types Integer Character Boolean

Integer Data Type A type Integer object represent only whole numbers. Not all integer range can be represented inside a computer. On each system, the predefined constant MaxInt is the largest possible integer. The smallest integer is -MaxInt-1 Objects: Variables Constants Literals Operations: Arithmetic: + - * / div mod div computes the integral part of the result of dividing the first operand by the second. mod returns the integer remainder of the result of dividing its first operand by its second. Assignment: := Standard procedures: ReadLn, WriteLn, Read, Write

What is MaxInt? PROGRAM MaximumInteger; BEGIN writeln('MaxInt = ', MaxInt) END. OUTPUTS: MaxInt = 32767

Division PROGRAM Division; VAR resint, dividend, divisor : integer; resreal : real; BEGIN dividend := 13; divisor := 4; resreal := dividend / divisor; resint := dividend DIV divisor; write('resreal = ', resreal:5:2); write(' resint = ‘, resint); writeln(' mod = ', dividend MOD divisor); readln; END. OUTPUTS: resreal = 3.25 resint = 3 mod = 1