Usually in a file in secondary storage. If the file does not already exist, the program will ask the operating system to create it.
Most collections of data outside of main storage are organized into files. Keeping track of all this information is one of the jobs of the operating system. If the computer is part of a network, keeping track of all the files on all the computers is a big job, and involves all the operating systems on the network.
Application programs (including programs that you might write) do not directly read, write, create, or delete files. Since the operating system has to keep track of everything, all other programs ask it to do file manipulation tasks. For example, say that a program has just calculated a set of numbers and needs to save them. The following might be how it does this:
So when an application program is running, it is constantly asking the operating system to perform file manipulation tasks (and other tasks) and waiting for them to be completed. If a program asks the operating system to do something that will damage the file system, the operating system will refuse to do it. Modern programs are written so that they have alternatives when a requests is refused. Older programs were not written this way, and do not run well on modern computers.
In modern computer systems, only the operating system can directly do anything with disk files. How does this:
(You might not be certain about your answers, but please think about the questions.)