A particle of mass m slides down on the curve $z=1+\frac{x^2}{2}$ in the $xz$-plane without friction under the action of constant gravity.Suppose $z$-axis points vertically upward.Find the Lagrangian of given system.
The position vector of the particle is given by $\overline r=(x,0,1+\frac{x^2}{2})$. Then the velocity vector is given by $ \dot {\overline r}=(\dot x,0,x\dot x)$. So the kinetic energy is given by $T=\frac {m}{2}((\dot x)^2+x^2(\dot x)^2)$. Now I am confused in potential energy. The potential energy is given by $V=mgz$ but what will be the sign of it? What does it mean that $z$-axis points vertically upward?

The movement is restricted to the manifold $f(x,z) = 1+\frac 12 x^2-z=0$. The potential energy is taken having a referential plane as for instance, the plane $XY$ so the potential energy is given by $m g z$. The Lagrangian is given by
$$ L = T - V +\lambda f = \frac 12 m(\dot x^2+\dot z^2) - m g z + \lambda\left(1+\frac 12x^2-z\right) $$
giving the movement equations
$$ \cases{ \ddot x = -\frac{x(g+\dot x^2)}{1+x^2}\\ \ddot z = \frac{\dot x^2-g x^2}{1+x^2}\\ \lambda = -\frac{m(g+\dot x^2)}{1+x^2} }\ \ \ \ \ \ \ \ (*) $$
Here $\lambda$ represents the reaction force along $f(x,z)=0$
NOTE
According to Euler-Lagrange formalism, the movement equations are
$$ \cases{ m\ddot x -\lambda x=0\\ m\ddot z+\lambda+mg=0\\ 1+\frac 12 x^2=z} $$
now deriving twice the $f(x,z)=0$ manifold we obtain the third equation substitution as
$$ \ddot z= x \ddot x +\dot x^2 $$
now solving
$$ \cases{ m\ddot x -\lambda x=0\\ m\ddot z+\lambda+mg=0\\ \ddot z= x \ddot x +\dot x^2} $$
for $\ddot x,\ddot z,\lambda$ we obtain $(*)$