A digital camera works by capturing light through a lens, converting it into an electronic image, and storing that image on a digital memory card. When you press the shutter button, the camera's sensor, which is usually a CCD or CMOS chip, is exposed to light. Each sensor element (or pixel) converts the light into an electrical charge.
The camera's image processor then reads this charge and converts it into a digital image file, usually in a format such as JPEG or RAW. This file contains information about the color and brightness of each pixel in the image.
The digital image is then stored on the camera's memory card, which can be transferred to a computer or other device for viewing and editing. The camera's LCD screen allows you to preview and review the images you have taken.
When it comes to focusing, most digital cameras use a combination of contrast detection and phase detection autofocus systems to ensure that the image is sharp and in focus.
In summary, a digital camera works by capturing light through a lens, converting it into an electronic image, and storing that image on a digital memory card through a series of complex processes involving sensors, processors, and memory components.