- When the argument is sent by value, the original value of the argument does not change after the SUB-Program of function call. To pass the argument by value argument variable is enclosed in parenthesis.
- Eg: A program to find the sum of the square of the digits in given number.
CLS
INPUT "Enter the ending value of the series"; n
PRINT "The value of n before calling the SUB procedure is "; n
CALL sum ((n))
PRINT "The value of n after the completion of the SUB procedure is "; n
END
SUB sum (n)
s = 0
WHILE n <> 0
r = n MOD 10
s = s + r ^ 2
n = n \ 10
WEND
PRINT "The sum of the square of the digits is "; s
END SUB
- Explanation:
- Here, if the user run the program giving the value 45, the output value of n before calling the SUB procedure will be 45.
- And the value of s will be 41.
- And the value of n after the completion of SUB procedure will be 45.