course.wilkes.edu/CS125Labs
Welcome to the site for CS 125 labs!

 

Experiment 3: Naming Parameters and Arguments

The Question: If a value parameter has the same name as its corresponding argument, will altering it alter the corresponding argument?

Hypothesis: Review the value parameter definition, and then construct a hypothesis.



The Experiment: Modify the definition of Change(), so that its parameter-names match the argument names:

void Change(int arg1, int arg2, int arg3)
{
    arg1 = 1;
    arg2 = 2;
    arg3 = 3;
}
(Hint: To make it easier to undo this modification, use copy-and-paste to make a copy of the function with the original names; surround one of the copies with a block comment, and modify the uncommented function.) This function is called in the main program with the statement:
   Change(arg1, arg2, arg3);
so that if giving parameters the same names as their arguments is a problem, compiling params.cpp will produce errors.

Observation: Translate your source program. What is displayed ?





Conclusions: Review the definition of a value parameter, and record your conclusions.





Undo your modifications and then continue.

 
  Home

Help

Lab 0

Lab 1

Lab 2

Lab 3a

Lab 3b

Lab 4

Lab 5

Lab 6

Lab 7

Lab 8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13



Membership

Login




Last update: Wednesday, August 23, 2000 at 3:10:03 PM.
visitors to this page.