Anyone who has ever seen a tank will know that it has as its main weapon a rather large gun that is mounted on an armored platform, called a turret, which is capable of turning a full 360 degrees. When I say large, I mean that the gun has a caliber ranging from 105 to 150mm. If you think that's small, understand that the shells the gun fires are between 10.5 and 15 centimeters across. For some perspective, a 12.7mm round to the shoulder would take your entire arm off, so imagine what would happen if something that big hit you. Most tank guns have barrels that are smooth, though there are slightly better ones, usually British, that are rifled. What this means is that the canon has internal grooves, not unlike those you'd find on a candy cane, that vastly improves its accuracy so it doesn't just 'hit something over there'.
These magic wands of death typically fire two different kinds of rounds (a fancy military term for a big, exploding bullet): armor piercing and high explosive. Now the people who design tanks would very much rather not have them exploded by other tanks, so obviously they try their very best to make them as least likely to get blasted apart as possible by covering them in armor specifically designed not to get penetrated by rounds fired from their enemies. This is why armor piercing rounds, as its name suggests, are specifically designed to try and pierce such armor. High explosive shells, on the other hand, are meant for blasting apart specially strengthened buildings you might have the misfortune of attempting to hide in on the battlefield.
Now there is no point having all of this if you can't aim your nice, big gun properly, so the tank people have used and developed fancy ways of making sure the tank round hits whatever the gunner (or tank commander, depending on who's boss) wanted to hit instead of some poor sod's house. In the good old days of World War II, this was accomplished, albeit not with complete success, by actually looking at the target with your eyes via either a periscope, which was the safest way at that time, or by opening a hatch on top of the tank and peeking out at the surrounding environment, though doing this would expose your precious noggin to sniper fire. Today's tanks have all sorts of fancy technological wizardry that use different types of sensors, computers and of course physics to make sure the the gun's shells hit the correct target.
Tanks sometimes have to fire their canons while moving, and because canons are very big and heavy things, they tend to flop about when the tank is rolling. This would obviously make aiming and firing rather difficult, so they have to be stabilized by a gyroscope, which is basically a much more expensive and complicated version of that spinning, top-like thing you had as a toddler. Tank guns also tend to be fitted with muzzle brakes, which are specially designed caps put on their ends to prevent the canons from jerking back excessively when they fire their big, heavy rounds.
If you have ever played with fireworks, you will know that gunpowder emits a lot of nasty, putrid smoke, and gunpowder is still used to fire tank rounds today, which is why a fume extractor, usually attached to the gun somewhere in the middle, is needed to stop fumes from entering the crew compartment. This is very important because there's no point having a tank when its crew is dead from breathing in too much of that toxic smoke. Also, something called an insulating thermal jacket is sometimes wrapped around the entire barrel (the long, protruding part of a gun) to prevent it from getting bent when used for extended periods of time. This rather unpleasant side effect happens when the extreme heat released during the firing of rounds isn't distributed evenly, causing the hotter bits of the gun to expand more quickly than the relatively cooler bits.
Bear in mind that there will be very unhappy people trying to knock out your precious tank with rockets and bazookas, and you will have to shoot them to make sure that they don't, but using your tank's main canon to fire at people is quite pointless for two reasons - one: that big gun can't be fired fast enough (normal firing rates are a few rounds a minute) to kill every single bazooka-toting Afghan running at you, and two: you DO NOT need a fifteen centimeter bullet to kill a reasonably sized human being. This is why all tanks have smaller normal machine guns, usually with a caliber of 7-8mm, mounted right next their main guns. Also, if your enemy is smart, he might try to drop bombs on your tank with a helicopter, or if he's both rich and smart, a jet, so bigger 12.7mm anti-aircraft machine guns are usually mounted on the roof to turn any aircraft the Iraqis throw at you into flaming piles of very expensive scrap metal. Oh yes, war sounds like fun now doesn't it?