A code is said to be malicious-code if it creates unanticipated or undesired effects created/written with intent to damage.
A virus is a program that can replicate itself and thereby pass on malicious code to other non-malicious programs.
They have been named as ‘virus’ because they act similar to the biological viruses’ behavior in our body.
A attacker may create a good program and hide inside it a ‘virus’ whereby the good program goes on to affect other programs in system. (e.g. Hiding a virus inside FIFA2017)
A virus infection often spreads in a geometric rate which eventually affects the entire system and later affects all the other systems connected to it (via a network).
A virus can be one of the two types: Transient OR Resident.
A transient virus has life-span which depends on its host program.
It runs when its attached program executes and terminates when its attached program ends.
A resident virus locates itself in memory.
There inside memory it can remain activated or be activated as a stand-alone (independent) program even after the host program ends.
Examples of some viruses are: Storm virus, Melissa Virus, The concept virus