# Exercise 2
In the following code, notice that variable i is declared on line 7. Variable j is declared on line 9, and then again on line 13. Will this code compile successfully or not?
Answer the question without running the code in your IDE. Explain your answer.
using System;
class MainClass
{
public static void Main(string[] args)
{
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
{
Console.WriteLine(j);
}
for (int j = 0; j < 10; j++)
{
Console.WriteLine(j);
}
Console.WriteLine(i);
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20