Sometimes it can happen that without coming to mind the camera on your iPhone stops working. No need to worry, it can be fixed if it is something software.
The first thing is to restart the phone to check if the camera software is reactivated. We can turn it off and on again or we can do a hard reset.
If this still does not work, try to access the restrictions section where access to the camera and other functions of your iPhone is disabled. Go to Settings -> General -> Restrictions
If it is active we will see that the allowed ones have the camera, it will have to be activated in case it is deactivated and we will be able to use it. In this case the phone needs to be restarted to avoid problems with using the camera.