Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMP 131 Introduction to Computer Programming

Similar presentations


Presentation on theme: "CMP 131 Introduction to Computer Programming"— Presentation transcript:

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

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

3 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

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

5 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 = resint = 3 mod = 1


Download ppt "CMP 131 Introduction to Computer Programming"

Similar presentations


Ads by Google