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