why do we need both npn and pnp transistors?
The PNP Transistor is the exact opposite to the NPN Transistor device. All the polarities for a PNP transistor are reversed which means that it "sinks" current as opposed to the NPN transistor which amplifies current.
The main difference between the two types of transistors is that holes are the more important carriers for PNP transistors, whereas electrons are the important carriers for NPN transistors.
PNP transistors use a small output base current and a negative base voltage to control a much larger emitter-collector current.
Generally, the PNP transistor can replace NPN transistors in most electronic circuits, the only difference is the polarities of the voltages, and the directions of the current flow. PNP transistors can also be used as switching devices.
You may think what is the point of having a PNP Transistor, when there are plenty of NPN Transistors available that can be used as an amplifier or solid-state switch?. Well, having two different types of transistors "PNP" and "NPN", can be a great advantage when designing amplifier circuits such as the Class B Amplifier which uses "Complementary" or "Matched Pair" transistors in its output stage or in reversible H-Bridge motor control circuits were we want to control the flow of current evenly in both directions.
A pair of corresponding NPN and PNP transistors with near identical characteristics to each other are called Complementary Transistors for example, a TIP3055 (NPN transistor) and the TIP2955 (PNP transistor) are good examples of complementary or matched pair silicon power transistors. They both have a DC current gain, Beta, ( Ic/Ib ) matched to within 10% and high Collector current of about 15A making them ideal for general motor control or robotic applications.
Also, class B amplifiers use complementary NPN and PNP in their power output stage design. The NPN transistor conducts for only the positive half of the signal while the PNP transistor conducts for negative half of the signal. This allows the amplifier to drive the required power through the load loudspeaker in both directions.