Hello,
Hmmmmm....in the function multiply() how did you go from parameters x and y to i and j, that looks like a "call-by-reference" but i don't understand why you did that and how it works
» One aspect of C functions may be unfamiliar to programmers who are used to some other languages, particularly Fortran, is
Call by Value. In C, all function arguments are passed "by value". This means that the called function is given the values of its arguments in temporary variables rather than the originals. This leads to some different properties that are seen with "call by reference" languages. The main distinction is that in C the called function cannot directly alter a variable in the calling function; it can only alter its private, temporary copy.
Call by value is an asset, however, a liability. It usually leads to more compact programs with fewer extraneous variables, because paramaters can be treated as conveniently initialized local variables in the called routine. For example, here is a version of power that makes use of this property:
int power(int base, int n) {
int p;
for (p = 1; n > 0; --n)
p = p * base;
return p;
}
int main() {
int x = 2, y = 3;
printf("%d\n", power(2, 3));
printf("%d\n", power(x, y));
return 0;
} The paramater
n is used as a temporary variable, and is counted down until it becomes zero. Whatever is done to
n inside
power has no effect on the argument that
power was originally called with.
and what does the function putchar() mean
» The function,
putchar(), writes a character to the current position in the standard output (stdout) and increases the file pointer to point to next character.
what is call-by-reference???
» An argument passing convention where the address of an argument variable is passed to a function or procedure, as opposed to where the value of the argument expression is passed.
-
Stack
Overflow