Antivirus and Firewall are different program for different purpose.
The prime job of an anivirus is protect your system from computer viruses. Your computer may be standalone or part of network or connected to Internet you need an antivirus program. It actively monitors when you are using your system for any virus threat from different sources. if it found one it tries to clean or quarantine the virus ultimately keeping your system and data safe.
Firewall is in other hand a program which protects your system from outsider/intruder/hacker attacks. These attacks may not be virus type. In some cases hackers can take control of your system remotely and steal your data or important information from system. If your system is directly connected to internet or a large network than you can install a software firewall in your PC to protect your self from unauthorized access. Firewall is available either in software or in hardware form. For a single PC you may need a software firewall while a large corporate implements hardware firewall to protect all of their systems from such attacks.
Now-a-days hybrid firewalls are available where they can protect your system from outside attack and even from virus threats.
Just a simple concept (not technically explaining it) to understand the difference between Anti-Virus and Firewall.
Anti-Virus is like a police force which finds the criminals(virus) and destroys it.
Whereas Firewall is like a fence with gate having GateKeeper or Watchman who will allow only authorised person (ex. Website) into the campus(network).
Antivirus and firewall both have the different concept, but both protects your computer from viruses.
Antivirus software generally used to protect your computer from virus where as firewall protects your computer from unauthorized access through network/internet such as hacking.
It is necessary to install a firewall and switch it on if you are connected to internet.
Virus - Vital Information Resources Under Siege. It is a program which affects your computer programs or files, and may damage your files, and may seriously damage your system. Virus can copy itself and affect another files.
Anti-virus can only fight against potential threat from the viruses, where as Firewall's protect your system/network from the intruders. So only using Firewall you can't protect your system from virus attacks, and only using Anti-virus you can't protect your system from intruders.