note_04 - 52 Predefined Functions Name Type of Argument...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 52 Predefined Functions Name Type of Argument Type of Result Example Value of Example abs integer integer abs (-2) +2 real real abs (-2.4) +2.4 round real integer round (2.6) 3 trunc real integer trunc (2.6) 2 sqr integer integer sqr (2) 4 real real sqr (1.100) 1.2100 sqrt real or integer real sqrt (4) 2.0 53 Chapter 4 Procedures Top Down Design : Breaking a programming task down into smaller & smaller unique subtasks & solving these subtasks using smaller and simpler algorithms (Implemented by writing Procedures or Function for each subtask). 1.) Easier to understand and implement the smaller subtask. 2.) Easier to write-test-debug a small subtask. 3.) More efficient use of your programming team, therefore more cost efficient. 4.) Easier to modify & maintain this structured software. 54 General Format Procedure Name ( Formal Parameter List ); Declarations (var, const etc); Begin Body of the Procedure End; Placement : When the procedure is coded in the same file as your main program, the procedure must be placed: 1.) After main program declarations. 2.) Before main program’s body. 55 Program program BriefEncounter; const Blank = ‘ ‘; var FirstName, LastName: string [10]; FullName: string [21]; Procedure Compliment ; {The procedure definition} Begin{ Compliment } writeln (‘A Lovely name.’); writeln (‘One of my favorites.’) End; 56 Program Cont . Begin { Program } writeln (‘Please tell me your first name.’); readln (FirstName); Compliment ; { PROCEDURE CALL } writeln (‘And what is your last name?’); readln (LastName); Compliment ; { PROCEDURE CALL } FullName := FirstName + Blank + LastName; writeln (‘Pleased to meet you ‘, FullName) ; End. { Program } 57 3 Flows of Data Communication Between Subroutines: 1-Way-In → Calling Routine passes data to called routine....
View Full Document

This note was uploaded on 03/27/2008 for the course CPSC 110 taught by Professor Logan during the Spring '07 term at Texas A&M.

Page1 / 21

note_04 - 52 Predefined Functions Name Type of Argument...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online