Download presentation
Presentation is loading. Please wait.
1
Warm-up: Dry Run DIV / MOD 2nd If Then Program
Computer Science 1 Warm-up: Dry Run DIV / MOD 2nd If Then Program
2
Learning Targets Be able to Dry Run a program that uses if
Understand how to use DIV and MOD. Write a program Review for Thursday’s quiz by completing a practice quiz.
3
Dry Run the following program ifOne; var a,b:integer; begin a:= 10;
if a>b then a:= a - 4; b:=b+1; end; writeln(a,b); readln; end.
4
DIV Pascal’s Integer Division
How can you get an integer result when you divide? For example, if you divide 5 by 2 what do you think the answer would be? What about the remainder. Pascal has math operations for finding the result of integer division and the remainder of integer division.
5
DIV and MOD DIV is used to find the result of integer division
For example X := 13 DIV 5; X:= 21 DIV 10; X:= 20 – 8 DIV 3; x:= 1 DIV 2; MOD is used to find the remainder of integer division X := 13 MOD 5; X:= 21 MOD 10; X:= 20 – 8 MOD 3; x:= 1 MOD 2;
6
DIV and MOD samples Ans:=23 DIV 10; Ans:= 14 DIV 4; Ans:= 52 DIV 5;
Ans:= 23 MOD 10; Ans:= 14 MOD 4; Ans:= 52 MOD 5; Ans:= 14 MOD 3; Ans:= 8 MOD 9; Ans:= 5 MOD 10; Ans:= 4.13 MOD 2;
7
Program options. Input: The amount of change (Integer value, like 66 cents) Output: The least amount of coins it takes to make the change: For 66 cents 2 Quarter(s) 1 Dime(s) 1 Nickel(s) 1 Penny/Pennies Input: The number of Chirps per minute for a cricket. Output: The outside temperature in Fahrenheit and give an appropriate statement if the temperature is greater than 90 degrees F. Using his equation, called Dolbear's Law, you can determine the approximate temperature in Fahrenheit, based on the number of cricket chirps you hear in one minute. Dolbear's Law: T = 50+[(N-40)/4] T = temperature N = number of chirps per minute Push: Add other comments for different temperatures, The above equation is for field crickets, look up equations for different types of crickets.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.