Character Array Complement

closed account (LEw7X9L8)
thanks
Last edited on
I would write a complement() function.
Use switch-case syntax could help here

1
2
3
4
5
6
7
8
9
10
11
12
13
14
char DNA_complement(char base)
{
   switch (base) {
     case 'A':
       return 'T';
     case 'G':
       return 'C';
     case 'T':
       return 'A';
     case 'C':
       return 'G';
   }
   // might also want to handle some error if it's not A,G,T, or C.
}


And then you would call complement() inside a for loop that goes through each character.

This tutorial talks about control statements and loops:
http://www.cplusplus.com/doc/tutorial/control/


Also, lol. I don't get why you people close your accounts. Afraid your teacher finding out??
Last edited on
Topic archived. No new replies allowed.