ANSWERS: 4
  • You can use local variables only in the form where they are declared. But global variables can be used throughout the project((Which may contain many forms))
  • . Local and global variables: http://www.cut-the-knot.org/books/Reviews/DiscreteAlgorithmicMath.shtml http://books.google.com/books?id=gT6o38Lv2DEC&pg=PA55&lpg=PA55&dq=mathematics+global+and+local+variables+programing&source=web&ots=PjDC1Q5HEa&sig=tBCW4AM9FexcBUpScmxxRtNO9sc - - - - [Here is an EXCERPT from the website for you] - - - - However, AL does allow global variables whose scope is the body of the algorithm, which makes them available to both functions and procedures for modification. Thus, the AL syntax permits functions to generate "side effects". The authors do not condone and even advise against this practice, but place no formal restrictions that could prevent it. There is also some confusion in the treatment of global and local variables. For example, the namesake of a function is declared a global variable: p. 112 The rules for what variables are local are exactly the same as for procedures, and thus in a function every non-global variable except funcname is local; only funcname affects higher levels. I take an exception with this exception: funcname is still not a global variable. On the whole, much of the confusion could have been avoided by introducing two standard attributes - scope and life span - of every variable. This would help obviate repeated and confusing discussions of variables "with the same name": p. 83 However, when the values at each stage do not have to be saved for the next stage, it's convenient and efficient in the algorithm to call the quantities by the same name each time through the loop. I am just curious what the use of a loop would be if the variables within its scope had names different from one pass to another. And further on the same page: Nevertheless, we do have to do some saving from one pass through the loop to the next. This is accomplished using the temporary variable rem. repeat until denom = 0 quot <- [num/denom] rem <- num - (quot × denom) num <- denom; denom <- rem endrepeat There is nothing saved from one pass through the loop to the next. The variable rem is indeed temporary (in a colloquial sense), but I guess its scope is limited by the repeat/endrepeat construct. Lastly, the authors seem to have a soft spot for recursion: p. 94 While procedures and functions do not have to involve recursion, their use to implement recursion will be their main purpose in this book. This is an unnecessary declaration, but it looks like the authors really meant it. For example, in a discussion of the recursive algorithm EUCLID-RECFUNC, they explain p. 95 Think of it this way: Each time function gcdf is invoked, it is as if a new copy of its definition is made, but one in which the new values for i and j are substituted. The previous copy is interrupted but is still there to be returned to later at the place where it was interrupted. Similarly (and additionally), for the HANOI algorithm: p. 101 The first invocation of H within H(3, 1, 3), namely, H(2, 1, 2), causes us to interrupt the normal sequential execution of steps of the algorithm and go back to the beginning of a new copy of the procedure. .
  • Try to read this you will have the idea i am using the c# code. public static void function1() { integer i=0; //i is global variable to this function // and this can be called any where in this function. if (i==0) { integer j=i; // j is the local variabel to this if condition // and can not be access out side this condition } if (i==0) { // this will raise error since j is not declare // j is only available in it's scope . // but will access the i as it is declared at function level. consol.writeline(j); } }
  • You will find the answer here http://visualbasic.freetutes.com

Copyright 2020, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy