[Tex/LaTex] Increment counter in TikZ

counterstikz-pgf

How to increment counter in TikZ using code below:

\newcounter{ga} %counter
\setcounter{ga}{1}
\begin{tikzpicture}
    \foreach \t in {1,...,10}{
      \pgfmathparse{Mod(\t,2) == 1 ? 1 : 0}
      \ifnum\pgfmathresult > 0
         \ga = \ga + 1
      \fi
\end{tikzpicture}

In line 4 I need something similar to \ga = \ga + 1.

Best Answer

\documentclass{minimal}
\usepackage{tikz}
\newcounter{ga}\setcounter{ga}{1}

\begin{document}

\foreach \t in {1,...,10}{\ifodd\t \stepcounter{ga}\fi}
\thega
\end{document} 

and an example with placing the value in a node:

\documentclass{minimal}
\usepackage{tikz}
\newcounter{ga}\setcounter{ga}{0}
\begin{document}

\begin{tikzpicture}
\foreach \t in {1,...,10}{\ifodd\t \stepcounter{ga}\fi}
\node [circle,draw] (a) at (0:1) {\thega};
\end{tikzpicture}

\end{document}