Count the total number of valence electrons of carbon and oxygen atom. The outer (valence) shell configuration of carbon and oxygen atoms are: 2s22p2 and 2s22p4 respectively.
The valence electrons available are 4+6=10.
Step 2: Skeletal structure
The skeletal structure of CO is written as:CO
Step 3: Octet completion
Draw a single bond (one shared electron pair between C and O and complete the octet and the remaining two electrons are the lone pair on C.
This does not complete the octet of carbon and hence we have to resort to multiple bonding (in this case a triple bond) between C and O atoms. This satisfies the octet rule condition for both atoms.