Experiment 8: auto Scope, Part II


The Question: What happens if we declare a name in a block, and then redeclare that name in a block nested within that block?

Hypothesis: Review the rules of scope, and then construct a hypothesis.



The Experiment: We can answer this question by surrounding our char declaration of arg1 with braces:

   int main()
   {
      int arg1;
      arg1 = -1;
      ...
      {
         char arg1 = 'A';
      }
   }

Observation: Translate your source program. What is displayed ?





Conclusions: Review the rules of scope and explain what happened.






Back to the Lab Exercise

Forward to the Next Experiment


Copyright 1998 by Joel C. Adams. All rights reserved.