UMBC CS 201, Spring 03
UMBC CMSC 201 Spring '03 CSEE | 201 | 201 S'03 | lectures | news | help

Local Variables

In the factorial example there were actually two functions -- main and Factorial. Each function declares some variables:

In general, when inside a function, you can only refer to the variables declared within it, its local variables. The formal parameters of a function are also local variables that may be used within that function.

What happens if we have two variables with the same name? -- You will always be using the local one.


CSEE | 201 | 201 S'03 | lectures | news | help

Wednesday, 22-Jan-2003 12:59:26 EST