Gauss-Bonnet-Chern theorem
Solution 1:
Let $\nu: M \to \mathbb S^n$ be a normal unit vector field along $M$, then the derivative $d\nu$ of $\nu$ maps $T_pM$ to $T_{\nu(p)}S = \nu(p)^\perp = T_pM$ and the Gaussian curvature is given by $$K_p = \det(d\nu(p): T_pM \to T_pM)$$
Now the volume form on $M$ is given by $\mathrm{d}vol_M = \iota(\nu) \mathrm{d}vol_{\mathbb R^{n+1}}$, i.e. for tangent vectors $\xi_1,\dots, \xi_n \in T_pM$ we have $$\mathrm{d}vol_M(p)(\xi_1, \dots, \xi_n) = \mathrm{d}vol_{\mathbb R^{n+1}}(p)(\nu(p), \xi_1, \dots, \xi_n) = \det(\nu(p), \xi_1, \dots, \xi_n)$$
Now consider the pullback $\nu^\ast \mathrm{d}vol_{S^n}$ of $\mathrm{d}vol_{S^n}$ to $M$:
\begin{eqnarray*} \nu^\ast \mathrm{d}vol_{S^n}(p)(\xi_1, \dots, \xi_n) &=& \mathrm{d}vol_{S^n}\left(\nu(p)\right)\left(d\nu(p) \xi_1, \dots, d\nu(p)\xi_n\right) \\ &=& \det\left(\nu(p), d\nu(p) \xi_1, \dots, d\nu(p)\xi_n\right) \\ &=& K_p\cdot \det\left(\nu(p), \xi_1, \dots, \xi_n\right) \\ &=& K_p \; \mathrm{d}vol_M \end{eqnarray*}
Therefore $$\int_M K \; \mathrm{d}vol_M = \int_M \nu^\ast \mathrm{d}vol_{S^n} = \deg(\nu) \int_{S^n} \, \mathrm{d}vol_{S^n} = \deg(\nu) \cdot \text{Volume }S^n$$
For even $n$, we have $\deg(\nu) = \frac{\chi(M)}2$, so I guess one might consider this to be a generalization to odd dimensional manifolds.
Solution 2:
The Gauss Bonnet Chern theorem is a special case of the Atiyah-Singer Index theorem, applied to calculated to the index of $d + d^*$ on differential forms, considered as mapping from even-degree forms to odd degree forms, which is exactly the Euler characteristic.
For a general (oriented) closed manifold, this comes down to $$ \chi(M) = \int_M \mathrm{Eul}(TM),$$ that is, the Euler Characteristic is the integral over the Euler class of the tangent bundle of the manifold, which can be locally computed in terms of curvature. In two dimensions, the Euler class is just a multiple of the Gauss curvature times the volume form.
This holds for odd-dimensional manifolds as well (and simply states that the Euler genus is zero), and the orientability can be discussed away by either going to the oriented double cover of $M$ or by noticing that the integrand is still a well-defined volume density on $M$ even though it is not a proper differential form.
For the case with boundary, the formula is similar, but involves another curvature term, which is integrated over the boundary of $M$. See here, Thm. 1 for example. In the two-dimensional case (i.e. one-dimensional boundary), this integrand is the geodesic curvature of the boundary.