The "sensor' in a digital camera is actually an array of millions of tiny light-sensitive sensors that gather the light coming through the lens while the shutter is open. Each of these tiny sensors produces a "picture cell" or pixel – a dot of colour – in the resulting image. The image from a typical APS-C sensor has about 3200 rows of 4900 pixels, and so about 15.5 million pixels or mega-pixels.
A computer screen is also an array of pixels. If I had a computer with a screen with 3200 rows of 4900 pixels I could transfer the image from camera to computer, and when I displayed it it would just fill the screen. However, most screens are a lot smaller than this. Mine, for example, has only 1050 rows of 1680 pixels, so when I ask for the image to be shown it has to scale it down to about 30% to fit on the screen. Each screen pixel in the display will be an average of the pixels from around the equivalent position in the image. The software allows me to zoom in, so at 100% each screen pixel is the same as the equivalent image pixel, but then I can only see part of the picture and must scroll to see other parts of the picture. I can of course also zoom out, so that the image takes up only part of the screen. Either way, the display will usually show the amount of scaling as a percentage.
Note that I have made no mention of dots per inch, or resolution, as this has no bearing on how the image is displayed on the screen. Some cameras set it to 300, others to 240 or 72, but whatever it is set to, it will not affect the on-screen display.
Now let's consider printing, where resolution does matter. Typical ink-jet printers space their tiny dots of ink at about 300 to the inch – hence dots per inch, or dpi. The long side of my image is 4900 pixels, so to print it at 300 dpi would need paper 4900/300, about 16", on the long side. But my camera tells the computer that the image dpi is only 72, and printing at 72 dpi would need paper 68" on the long side. Printing with the dots so far separated would give a very poor picture, so, before printing, I need to change the dpi, which software like Photoshop (and many others) allows me to do. When Photoshop, and similar programs, change the dpi, they need to know whether to keep the same number of pixels (smaller print), or the same print size (more pixels), and you tell it this with the "resample image" check box. If you bring up the image size dialog, and change the 72 to 300, and leave the resample image box ticked, Photoshop will take your 4900×3200 pixels and insert extra pixels to make it 20,500×13,600 – that's a lot of extra pixels, and the resulting file will be enormous. Untick that box, and the pixel count stays the same but the document size will go down from 68" to 16" (and corresponding changes for the short side).
The 16" is too long for printing on 11.7" long A4 paper, so I would need to scale the image down a bit, to about 3500 pixels. Just as when displaying the image on screen, the computer will do some averaging to get my 4900 down to 3500. If I want to print at the larger A3 size, on the other hand, I haven't enough pixels, so the computer will insert extra to bring the long side up to 5300 pixels. In practice, I only do this if printing elsewhere, as the computer will automatically scale the image before printing on my own printer. The critical thing here is first to set the resolution and then, in a separate operation, scale the picture if necessary.
Considerations when sizing an image for display on the internet – the CPS gallery, for example, or facebook, or just for emailing to a friend – are somewhat different. Most people that view the image will do so on a monitor that is 1200 pixels or less on the long side, and often the picture area on screen will be a good bit smaller than this. For such purposes I would normally leave the dpi setting unchanged – it is not going to affect how it is displayed – and scale the picture down to 1200 pixels long. When saving the image I would use a JPEG quality of maybe 70%, but JPEG settings are a topic for another note. Someone viewing the image won't be able to make a great print from it, but if they want a print they should ask for a print-quality copy. If I need to put a file up for printing I will change the dpi, do any necessary sizing, save at maximum quality JPEG, store the file on Dropbox and send a link to the person who needs it.