1. ## Use of variable

can someone help me to verify the following variable is come from which line (in the below program):

ie. paramB used on line 39 is defined on line 35.

-The variable variableA on line 10 =34
-The variable variableB on line 10 =34
-The variable variableB on line 17 =34
-The variable variableB on line 19 =34
-The variable variableB on line 28 =27
-The variable variableB on line 41 =19
-The variable sum on line 28 =24
-The variable variableA on line 38 =38

Code:
```01   #include <stdio.h>
02
03   int variableA;
04   float variableB;
05
06   float functionC(int variableB);
07
08   void functionA(int variableA, float paramA) {
09     variableA = variableA + 1;
10     variableB = variableA;
11     paramA = functionC(variableA);
12   }
13
14   int functionB(int paramA, double paramB) {
15     int variableB;
16
17     variableB = paramB + 1;
18     functionA(variableB, 1.2);
19     return paramA + paramB + variableB;
20   }
21
22   float functionC(int variableB) {
23     int index;
24     int sum = 0;
25
26     for (index = 1; index < variableA; index++) {
27       int variableB = 4;
28       sum += variableB;
29     }
30     return sum * 1.2;
31   }
32
33   int main() {
34     float paramA = 3.5;
35     int paramB = 2;
36     int result;
37
38     variableA = 0;
39     result = functionB(paramB, paramA);
40
41     variableB = functionC(result);
42   }```

2. can someone help me to verify the following variable is come from
Would you care to try that again, in English this time? And why the hell are you passing variables to you function when you have global variables called the exact same thing? Oh, while we're at it, main returns an int. Always.

Quzah.

3. > can someone help me to verify the following variable is come from:
You tell us what you think, then we'll correct any mistakes you make

4. sorry that I used void main ().
I will correct it in the future.

5. If you really want to know what each variable is, print it out.
Code:
`printf("On line %d, variableA is %d\n", __LINE__, variableA );`
Quzah.

6. what is __LINE__ mean in the printf statement?
the number 01,02,03.... start at left side indicted the line number.
it is remove while compiling in C.

7. __LINE__ is a preprocessor macro which turns into whatever line number it's on. Like so:
Code:
```#include <stdio.h>
int main( void )
{
printf("line: %d\n", __LINE__ );
printf("\n");
printf("line: %d\n", __LINE__ );
printf("line: %d\n", __LINE__ );
printf("line: %d\n", __LINE__ );
printf("\n");
printf("\n");
printf("line: %d\n", __LINE__ );
return 0;
}```
So, when used as I've illustrated, you can use it to display the line number in your program. Combine with whatever variable you're trying to display, you can end up seeing what the value of that variable is when you're on a given line number in your program. Not the greatest debugger, but it'll work in a pinch.

Quzah.

8. I only want to know, ie,

for the statement sum+=variableB;,

the variable sum is defined at the

statement int sum=0;,

is it correct?

9. Yes you are correct.

It's just an exercise to allow you to figure out scope, by creating globals, parameters and local variables with the same name.