You are on page 1of 2

div, mod

It is important to observe that when dividing numbers often


times the answer isn't a whole

number. For example 3 / 2 = 1.5. The problem here is that when


you divide two integers such as

3 and 2 you get a 'real' number. So there are two reserved words
in Turbo Pascal that were made

specifically for dividing integers. 'div' is used to find out


how many times one number goes into

another number. So the code:

writeln('Three goes into eleven ', 11 div 3, 'times.');

will produce the output:

Three goes into eleven 3 times.

11 divided by 3 does not equal 3, but since three can only go


into 11 three full times the answer

to '11 div 3' is three. 'mod' will give the remainder:

writeln('Three goes into eleven ', 11 div 3, 'times with a

remainder of ', 11 mod 3);

This code will produce:

Three goes into eleven 3 times with a remainder of 2


After 3 goes into eleven three times(3 * 3 = 9) there are still
numbers left over to get eleven. so to get that number you use
'mod'. Here is another example:

writeln('25 goes into 867 a total of', 867 div 25, ' times
with a remainder of ', 867 mod 25);

This prints:

25 goes into 867 a total of 34 times with a remainder of 17

Make sure and READ your questions properly. Take your


time – DO NOT OVER ANALYSE QUESTIONS!!!

For the algorithm/programming, MAKE SURE and put in


start and stop and declare your variable(s) at the top and
make sure and test it on scrap.

Go over ALL your notes on programming.


 Go over doing queries in Databases.
 Go over Hardware Specifications and Note 1.8.
 PLEASE GO OVER BINARY!!! PLEASE!!!
 Go over the note with how the hard drive works.
 GOOD LUCK! 

You might also like