The ans is D : none of this
It is given to us that :
a = 0
for (x = 1; x < 31; ++x)
for (y = 1; y < 31; ++y)
for (z = 1; z < 31; ++z)
if (((x + y + z)%3) = =0) <-This statement will execute 30*30*30 times.
a = a + 1;
It will execute 27000 times.
out of this for one complete iteration of the inner most loop if we see we will get 10 values for which the inner most condition will be satisfied and the value of a will be incremented. for 1st iteration:
1,1,1 ;1,1,4;1,1,7;1,1,10;1,1,13;1,1,16;1,1,19;1,1,22;1,1,25;1,1,28; i.e(31-1)/3=10
10 iterations because only 10 times we get a num which is one more than the multiple of 3 in the first iteration as see the value of x and y is fixed i.e 1+1 =2 so to satisfy the condition we need 1,4,7,so on so it is possible only for 10 values in the given range(arithmetic progression with common diff 3).
Next time also value of x and y will be fixed =1+2=3. Then the reqd no would be 3,6,9... so on for all iterations.
Total no of times the value of a will be incremented is 30*30*10=9000
So ans is 9000 and option D