Cattle are ruminants, so they spend most of their working day getting ready to be hamburgers by chewing their cud. To do that, they bring some of their upper stomach's (rumen's) contents back into their mouths to chew it into finer particles. Along with the solid and liquid materials come gaseous products of fermentation, principally methane, CO2, and some H2. The gases are also brought up in their own right through eructation ('belching'). Comparatively little finds its way to the far end, or cows would be so full of gas they would float to the moon (there is one recorded instance of this actually happening).