Unit 4

Topics: Variable, Ring, Real number, Value added tax / Pages: 4 (791 words) / Published: Oct 27th, 2013
Unit 4
1.Five advantages of using global variables.
It is accessible to all the modules in a program
You only have to declare it once outside the modules
It is good to use it for constants you want to keep consistent
It simplifies maintenance, avoids duplication of local constants.
It can make a program easier to read in reference to constants.
Five disadvantages of using global variables.
It makes debugging difficult
Any statement in a program can change the value
If modules use global variables it is dependent upon the module and if other modules are presented you have to redesign all over each time
It makes a program hard to understand since it can be modified and have to be aware of all other parts of the program that access it.
2. Global variables are not writing direct into flowcharts
3. Global variables are displayed in psesudocode but not in flowcharts directly
Short Answers
1. How do modules help you to reuse code in a program? It reduces the duplication of code within a program by reusing the module that was written once.
2. Name and describe the two parts that a module definition has in most languages. A header and a body, Header indicates starting point, and the body is a list of statements.
3. When a module is executing, what happens when the end of the module is reached? It’s executed and returned back to the point in main program where it was sidetracked from.
4. What is a local variable? What statements are able to access a local variable?
A variable declared inside a local module, only statement within a module
5. In most languages, where does a local variable’s scope begin and end?
Begins at the variables declaration within a module and ends at the end of the module in which the variable is declared.
6. What is the difference between passing an argument by value and passing it by reference? By value only a copy of the argument’s value is passed. By reference it’s passed into a special modification

You May Also Find These Documents Helpful

  • unit 4
  • Unit 4
  • Unit 4
  • unit 4
  • Unit 4
  • unit 4
  • Unit 4
  • Unit 4
  • Unit 4
  • Unit 4