We can prevent the computer against attack of viruses by installing proper antivirus, enabling the firewall, scan external devices before using on other computer, by avoiding emails that are suspicious or not known to us, should be very careful while downloading files or any programs from the internet etc.