Convergence of CG method I have a question like how can we mathematically prove that for a general matrix  Conjugate Gradient method will always converge within n steps in exact arithmetic ? where n is the size of the matrix.

When you use CG (or just about any of the common Krylov subspace methods), what you are really doing is solving a certain polynomial approximation problem.  Suppose you are trying to solve the problem $Ax = b$ using CG with starting guess $x_0$.  Let $x_k$ be the $k^\textrm{th}$ CG iterate, and let $e_k = x - x_k$ be the error at step $k$.  Let $\lambda_1, \ldots \lambda_n$ be the eigenvalues of $A$.  Then it can be shown that
$$
||e_k||_A = \inf_{p \in P_k} || p_k(A)e_0 ||_A \leq ||e_0||_A \inf_{p \in P_k} \max_{1 \leq j \leq n} |p_k(\lambda_j)|,
$$
where $P_k$ is the space of polynomials of degree at most $k$ and $||\cdot||_A$ is the vector norm defined by
$$
||v||_A = \sqrt{v^*Av}.
$$
The error in the CG iteration is thus determined by one's ability to generate polynomials that are "small" on the spectrum of $A$.  At the $n^\textrm{th}$ step, we are allowed to draw the optimal polynomial from $P_n$.  Since $A$ has at most $n$ distinct eigenvalues, you can choose $p_n$ to have roots at all of the eigenvalues of $A$, which reduces the error to zero.
As a corollary, if $A$ has fewer than $n$ distinct eigenvalues, the iteration will actually converge in fewer than $n$ steps!
See Lecture 38 in Trefethen and Bau's Numerical Linear Algebra for an excellent discussion of this.  The document in the link posted by Inquest is very good as well.
