Multiprogramming and multitasking are two techniques used in operating systems to make better use of the CPU. Although they are related, they differ in how they handle multiple programs or tasks.
Multiprogramming
Multiprogramming allows multiple programs to reside in the memory at the same time. In a multiprogramming system, the operating system simply switches to and executes another job when the current job needs to wait. The processor is shared among multiple programs, and each program is given a slice of time to execute. Multiprogramming allows multiple users to access system resources simultaneously.
Multitasking
Multitasking, on the other hand, allows a single program to execute multiple tasks simultaneously on a CPU machine. These multiple tasks share common resources like CPU and memory. In multitasking systems, the CPU executes multiple jobs by switching among them typically using a small-time quantum, and the switches occur so quickly that the users feel like they are interacting with each executing task at the same time.
In summary, the main difference between multiprogramming and multitasking is that multiprogramming allows multiple programs to reside in the memory at the same time, while multitasking allows a single program to execute multiple tasks simultaneously on a CPU machine.