A computer virus is a type of malware that, when executed, replicates by modifying other computer programs and inserting its own code. This distinguishes it from other malware types like Trojans (which disguise themselves but don't replicate) and worms (which are standalone and spread through networks).