(d)
$A = diag\ (d_{1},\ d_{2}\ldots\ldots.d_{n})$
Given, $A^{3} = A$
$\Rightarrow$ diag $\left( d_{1}^{3},\ d_{2}^{3},\ldots,d_{n}^{3} \right) = diag(d_{1},\ d_{2}\ldots,d_{n})$
$\Rightarrow d_{1}^{3} = d_{1},d_{2}^{3} = d_{2}\ldots,d_{n}^{3} = d_{n}$
Hence, all $d_{1},\ d_{2},\ d_{3}\ldots,d_{n}$ have three possible values$\pm 1,\ 0$. Each diagonal element can be selected in three ways. Hence, the number
Of different matrices is $3^{n}$