  Let $\{C_1, C_2, \ldots, C_m\},~m\ge2$ be a collection of $n\times n$ real
symmetric matrices. The objective of the paper is to offer an algorithm that
finds a common congruence matrix $R$ such that $R^TC_iR$ is real diagonal for
every $C_i;$ or reports none of such kind. The problem, referred to as the
simultaneously diagonalization via congruence (SDC in short), seems to be of
pure linear algebra at first glance. However, for quadratically constrained
quadratic programming (QCQP), if the quadratic forms are SDC, their joint range
set is a closed convex polyhedral cone, which opens the possibility to extend
the classical $\mathcal{S}$-lemma for more than two symmetric matrices. In
addition, under the SDC assumption of quadratic forms, QCQP can be recast in
separable forms which is usually easier to tackle. It is thus important to have
a standard procedure for determining whether or not the SDC property holds for
the underlined quadratic optimization problem. Our result solves a long
standing problem posed by Hiriart-Urruty in 2007.
