IBM SC34-5764-01 Manual page 91

Cics transaction server for vse/esa
Table of Contents

Advertisement

/******************************* REXX ********************************/
/* This function receives a list of numbers, adds them, computes
/* their average, and returns the average to the calling program.
/*********************************************************************/
ARG numlist
sum = 0
DO n = 1 TO WORDS(numlist)
number = WORD(numlist,n)
sum = sum + number
END
average = sum / WORDS(numlist)
RETURN average
Figure 44. Possible Solution
/* receive the numbers in a single variable */
/* initialize sum to zero */
/* Repeat for as many times as there */
/* are numbers
/* Word #n goes to number */
/* Sum increases by number */
/* Compute the average
Writing Subroutines and Functions
*/
*/
*/
*/
Chapter 6. Writing Subroutines and Functions
69

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Rexx

Table of Contents