Secondary armament

Secondary armament is a term used to refer to smaller, faster-firing weapons that were typically effective at a shorter range than the main (heavy) weapons on battleship- and cruiser-type warships. The nature, disposition, size and purpose of secondary weapons changed dramatically as the threat changed from torpedo boats, to torpedo-carrying destroyers, to aircraft, to anti-ship missiles.
Pre-dreadnought era.
Pre-dreadnoughts, from the period 1890 to 1905, were typically fitted with 3 or 4 different calibres of weapon. The main guns were usually approximately 12-inch caliber, secondary weapons usually 6-inch but typically in the range 5-inch to 7.5-inch. Guns smaller than 4.7-inch are usually considered "tertiary". (Many pre-dreadnoughts also carried 9.2 to 10-inch "secondary" guns, but these are usually treated instead as a mixed-caliber main armament.)
Secondary guns were "quick firers", and could fire 5 to 10 rounds per minute. It was this attribute, rather than their destructive power or accuracy, that provided the military value. Secondary guns were almost universally carried in "casemates", or a long armoured wall through which the battery of guns projected.
Such weapons were designed to fire at both capital ship targets and smaller targets such as torpedo craft and destroyers.
Small targets were of course vulnerable to 6-inch projectiles, and a high rate of fire was necessary to be able to hit a small and evasive target.
In this era, secondary weapons were also expected to engage capital ships. Heavily-armoured areas of battleships would not be vulnerable to 6-inch fire, but there were large areas that could not be heavily protected. These lightly armoured and unarmoured areas would be "riddled" at the expected ranges of perhaps 3000 yards. This would knock out the enemy's secondary armament, punch holes in the lightly armoured bow and stern, perhaps knock down funnels and spotting tops, and destroy the bridge and command positions. Secondary guns were a very important factor in battleship combat.
Dreadnought era.
Dreadnoughts were characterized by an "all-big-gun" armament. Broadly, this era spans from 1906, through the super-dreadnought era, to the end of World War I.
During this period, there was some variation in the selection of secondary weapon. British practice, at first, was to mount very small guns (3-inch and 4-inch) that were considered a tertiary battery. These guns were often mounted unarmoured in the open, or later, in a casemate battery. Later, the guns grew to 6-inch size. In other navies, the 6-inch size was commonly mounted throughout the era as a casemate battery.
British doctrine at first held that the small guns were for anti-torpedo defense only. Other navies, with a larger secondary battery, held that they should also be used against capital ships. For instance, German doctrine, for fighting in the North Sea, held that poor visibility provided a good opportunity for the shorter ranges at which smaller guns would be effective. Britain later came around to this point of view, although the primary justification for mounting a 6-inch battery (in the "Iron Duke" class) remained fighting against the increasingly large torpedo boats and destroyers.
Naval historians covering this period disagree on the value of the secondary battery. Arguing for, it provided protection against surface torpedo craft without needing a flotilla of supporting craft that smoked up the range and burdened the admiral with additional command, control and signalling. Arguing against, it consumed considerable displacement (2000 tons or more), were holes in the side close to the waterline that increased the risk of capsizing, and could not be heavily armoured yet were connected to magazines that threatened the destruction of the ship. There were also considerable difficulties in bringing secondary weapons into action with the main guns; they too smoked up the range, splashed and obscured their target, and might required maneuvers to open secondary arcs that put the main guns at a disadvantage. Battle experience showed that capital ships were almost always accompanied by their flotillas, secondary batteries were ineffective against capital ships, but that German battleship secondary batteries were very effective in the Jutland night action against British destroyers.
World War II.
With the emergence of the threat from air-delivered weapons, the nature of the secondary guns changed once more. Now they needed to be multi-purpose weapons, with a high-angle fire capability to engage aircraft, as well as the traditional use against destroyers. Although they were also used against capital ships, the extreme range of capital ship engagements (through superior optics and target prediction and, later, radar), meant they were not expected to achieve much.
High angle weapons could not be mounted in casemates. Thus, they migrated to small turrets mounted on the upper deck. In order to hit a fast-moving air target, a high rate of fire was required, thus secondary guns reverted slightly to the 5-inch from 6-inch size. Although 6-inch guns were still used by several navies including France, Germany, Italy and Japan in their new battleships; they were complemented by 4 to 5-inch guns as well.