For starters it is a very silly test. Ignore firms that give such a test with obfuscated code. Do not deal with idiots. Usually such tests are given by low-qualified programmers.
Take into account that an array designator used in expressions with rare exceptions is implicitly converted to pointer to its first element.
So this declaration
char ***c = b;
is equivalent to
char ***c = &b[0];
In this expression statement
*c++;
the dereferenced value of the pointer is not used. So this statement should be written like
c++;
After this statement the pointer c
points to the second element of the array b
.
You could rewrite the statement above like
c = &b[1];
Now let's consider the expression in the printf call
printf("%s\t", *++*c)
Dereferencing the pointer c
you get lvalue b[1]
that has the value a + 3
. Applying the unary operator ++ to this expression you will get a + 4
. And at last dereferencing this expression you will get the lvalue a[4]
that is outputted.
BREAK
Now consider the expression in the second call of printf.
printf("%s\t", **c + 2);
Dereferencing the pointer c
the first time you will get the lvalue b[1]
. After the first call of printf it contains the value a + 4
. Dereferencing this expression you get the lvalue a[4] that points to the string literal "BREAK". Adding 2 the pointer expression will point to the third character of the string literal. So there will be outputted
EAK
At last let's consider the expression in the third call of printf.
printf("%c", (*(**(c + 2) + 2) + 2));
As c points to b[1] then using the pointer arithmetic c + 2
the expression will point to b[3]
Dereferencing the pointer you will get the lvalue b[3]
that contains the value a + 1
. Dereferencing this expression you will get the lvalue a[1]
that points to the string literal "SURATH"
. Again applying the pointer arithmetic you will get a pointer that points to the third element of the string literal that is to the sub string "RATH"
. Dereferencing the pointer expression you will get the character 'R'
. Addi g to the character the value 2 you will get the character 'T' that is outputted
T
That is all.