# Rotation gates (CUDA-Q) [[r-gate|Rotation gates]] implementation using CUDA-Q. The example applies $R_x(\pi/2)$ to $\lvert 0\rangle$, producing $\frac{1}{\sqrt{2}}(\lvert 0\rangle - i\lvert 1\rangle)$. ```cpp // Compile: nvq++ main.cpp -o main // Run: ./main #include #include struct kernel { __qpu__ void operator()() { cudaq::qubit q; rx(M_PI / 2.0, q); // R_x(pi/2) on |0> mz(q); } }; int main() { auto counts = cudaq::sample(kernel{}); counts.dump(); // ~50% |0>, ~50% |1> } ```