In all cases, detectors should be installed to the manufacturer’s specifications.
Generally, smoke rises and therefore smoke detectors should be installed either on the ceiling or within 12” of the ceiling. A sloped ceiling or steeply pitched ceilings vary and you should consult a NH licensed electrician or someone from your fire department for placement.
Carbon monoxide (CO) is heavier than air and will sink close to the floor or ground. Therefore, CO detectors should be installed nearer to the floor. Generally, they plug into an outlet.
There are combination smoke and carbon monoxide detectors and these generally are installed near or on the ceiling. Again, following the manufacturer’s specifications are the best guidelines.