In the code below,I want to use variables a,b and n outside of the for loop where they are initially declared.for eg:in int S=a+b,the compiler cannot find the location of a and b.How can I do that?
{
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for (int i = 0; i < t; i++) {
int a = in.nextInt();
int b = in.nextInt();
int n = in.nextInt();
}
in.close();
int S = a + b;
for (int q = 1; q < n - 1; q++) {
S = S + 2 ^ q;
System.out.print(S + " ");
}
}
}