CMP 131 Introduction to Computer Programming - PowerPoint PPT Presentation

About This Presentation
Title:

CMP 131 Introduction to Computer Programming

Description:

Ordinal Data Types. Integer. Character. Boolean. Integer Data Type. A type Integer object ... On each system, the predefined constant MaxInt is the ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 6
Provided by: violettaca
Learn more at: http://www.cs.cmu.edu
Category:

less

Transcript and Presenter's Notes

Title: CMP 131 Introduction to Computer Programming


1
CMP 131Introduction 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 ', resreal52)
write(' resint , resint) writeln(' mod
', dividend MOD divisor) readln END.
OUTPUTS resreal 3.25 resint 3 mod 1
Write a Comment
User Comments (0)
About PowerShow.com