Wageningen University explains that DNA bases only pair with one other base, so the complementary DNA sequence can be read out by replacing each base with its complement and reversing the order. The complementary base pairs are A to T and G to C, so every G is replaced with a C and so on.
The reversal of the complementary DNA sequence is a matter of convention. DNA sequences are written from the 5' ("five prime") to 3' ("three prime") ends, but if the complementary sequence is written down opposite the original DNA sequence, it runs from the 3' to 5' ends.
This technique can also be used to determine the mRNA that is transcribed from a particular stretch of coding DNA. The only difference is that when writing an RNA sequence, the T, thymine, is replaced with U, uracil. Typically, the RNA sequence is identical to the coding, or "sense," strand of DNA with the exception of U instead of T bases.
Complementary DNA, or cDNA, can also refer to a strand of DNA that is synthesized based on an mRNA sequence that has been removed from a cell or organism. The synthesis of cDNA from mRNA is used in molecular biology techniques to allow work with only the DNA that codes for the protein sequence, rather than the protein's introns.