English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

to do with programming

2007-08-31 04:33:02 · 8 answers · asked by Anonymous in Computers & Internet Programming & Design

8 answers

In addition to having parameters, like a subroutine, a function returns a value. This means a function can be used in an expression, while a subroutine cannot.

2007-08-31 04:36:51 · answer #1 · answered by The Phlebob 7 · 4 0

Sub-routines and functions? huh? sound like we just need to define these terms.

Sub-routine: Any piece of code or logical instruction that make up one logical block. Any program that you run on your machine has at least one subroutine that performs the required task.

Function: In most programming languages there exists a construct called a function. A function is a piece of code that has a header and returns a variable when it is finished.

Now lets put this into context, one language where a dichotomy occurs in these two terms is visual basic. The short answer is that a subroutine does not have a return value and a function does have a return value in this context.

So in the final analysis, if this doesn't help, you need to ask a better question.

2007-08-31 04:42:36 · answer #2 · answered by Anonymous · 1 0

The concept of sub routines in programming became popular with the Basic language. A sub routine is exactly the same as a function, except it has no return type, it returns nothing. Personally, given the small amount of distinction between the two I find it confusing to use two terms for what is practically the same thing.

2007-08-31 06:54:23 · answer #3 · answered by Pfo 7 · 0 0

A function is a special type of subroutine. It always returns a single value. It can be used as part of an assignment or equation. For example, you could write a function which totals up a column of numbers - say "funcTotal_Column()". You could then make an assignment such as "x=funcTotal_Column()". When the program is run, the colum will be totaled and its value assigned to "x".

A routine may return multiple values (or no value) and can not be used in an assignment statement. For example, a rountine (say "Cal_Table(a,b,c,d)") would return the Total of the column as "a" (same as the funcTotal_Column), but also the length of the column (b), the average value (c), and the mid point (d). An assigment of "x=Cal_Table(a,b,c,d)" would make no sense. What would x equal, the total, average, length, or mid-point? so a routine can not be used in an assignment.

2007-08-31 04:45:48 · answer #4 · answered by dewcoons 7 · 1 0

Wrote a sub in a cellular? Sub or formula? are you able to provide us the element syntax? distinctive Sub(recurring) and overall performance: a million. Sub won't return values functionality will return values 2. Sub can not stated as from cells purposes can stated as from cells

2016-12-16 07:58:44 · answer #5 · answered by ? 4 · 0 0

Takes me back to FORTRAN days, in FORTRAN
the distiction of SUBROUTINES (not returning a
value) and FUNCTIONS (returning a value) was
made.

In Pascal they were all just Procedures and because
in C you are required a return type (even if its just void)
then they are functions.

And now I'm programming in C++ they're all just
methods. isn't it.

2007-08-31 11:46:35 · answer #6 · answered by RICHARD B 3 · 0 0

^ That's pretty much it. A function returns a value of some sort -- integer, decimal, string, or boolean. A sub doesn't return anything.

2007-08-31 04:40:40 · answer #7 · answered by Edward S 3 · 1 0

subroutine variables are local to the subroutine

2007-08-31 04:39:43 · answer #8 · answered by Anonymous · 1 0

fedest.com, questions and answers