Lecture-15(calling-subs or functions)

Lecture-15(calling-subs or functions) - Modular Programming...

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

View Full Document Right Arrow Icon
Modular Programming Lecture 15
Background image of page 1

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

View Full DocumentRight Arrow Icon
Motivation To make a program easier to understand – it is good practice to break it into parts or modules Modules comprise of a set of statements (50 – 100 instructions) that generally focus on a particular, well- defined sub-task Two types of procedures commonly employed as modules – sub (short for subroutine) and functions Subs can return several outputs (or results), whereas the function returns only one output or value (output is the same variable as the name of the function)
Background image of page 2
Sub Procedures The syntax is: Sub Main [(statements)] Call Name([arglist]) [(statements)] End Sub Main Program A sub-program called within the main program Sub Name ([arglist]) [(statements)] [Exit Sub] [(statements)] End Sub Sub Program Called within the Main Allows immediate Exit from the procedure prior to its completion
Background image of page 3

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

View Full DocumentRight Arrow Icon
Comment line A subprogram is called – Notice how the arguments are being passed to the Sub Notice that the names of the variables need not be the same. The assignment of variable values
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/27/2008 for the course PGE 310f taught by Professor Srinivasan during the Spring '08 term at University of Texas at Austin.

Page1 / 10

Lecture-15(calling-subs or functions) - Modular Programming...

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

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