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

 

Experiment 7: auto Scope, Part I

The Question: What happens if we declare the same name twice within a block, giving it two different meanings?

Hypothesis: Using your experience and intuition, construct a hypothesis.





Experiment 7: Add a declaration

   int main()
   {
      int arg1;
      arg1 = -1;
      ...
      char arg1 = 'A';
   }
just before the end of the main function. Since arg1 is declared near the beginning of the main function as the name of an int, redeclaring it as a char within the same block will answer our question.

Observation: Translate your source program. What is displayed ?





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





 
  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:24:30 PM.
visitors to this page.