Difference between firewall and antivirus

Hi,
I have doubt regarding firewall and antivirus.
My doubt is
The function of the firewall is to prevent unauthorised access
from the outside world to the computer system.Since the firewall
prevents unauthorised access there is no chance of virus,etc
Only firewall is enough.So Why ANTI VIRUS?

A firewall works based on a rule set. Standard firewall defaults are to DENY all. If you had this setup you are right no antivirus would be needed (with the exception of non internet infections, IE: cd, flash drive, ect). However most firewalls are not deny all. Since you would not be able to surf the internet with a deny all.

So this opens up the devices behind the firewall to possible infection. How some security companies have gotten around this has been with Proxy's and Unified threat management (UTM). This will add scanning of data and packets that go through for virus and other bad things.

The anti-virus is not a firewall. It does not block access to your network it just blocks access to your computer and certain items. If the antivirus is not detecting something bad it will let it through. Obviously the same goes for an antivirus application where you can have a deny all but realistically this is impractical. There are antivirus products that also have firewalls built in. These are still limited.

can firewall also be used to block the virus etc coming from the cd,dvd,pen drive?
or does Firewall blocks or unblocks data only coming from the internet?
can firewall also be used to remove or clean the virus etc from the computer if it already exists in the computer?or firewall does only the allowing or disallowing function?

Firewall tools are the software which prevent unauthorized communication between computer networks and host PC while antivirus software are the protection tools which prevents any kind of malicious threats like virus, malware, ransomware, backdoors etc from entering into your computer system. There are effective antivirus programs that may help in keeping your PC safe. Some of the popular ones are Norton Antivirus, Immunet Antivirus, Kaspersky Antivirus, Avast Antivirus, Bitdefender Antivirus etc.