forked from TheAlgorithms/C
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Bender
authored
Jan 26, 2018
1 parent
53e58d1
commit ee68f22
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
char *to_rna(const char s[]) | ||
{ | ||
|
||
/* determines the length of the given string */ | ||
int len = strlen(s); | ||
|
||
/* creates a return string */ | ||
char *ans = malloc(sizeof(char) * len); | ||
|
||
/* for the loop */ | ||
int i = 0; | ||
|
||
/* actual compile process */ | ||
for (i = 0; i < len; i++) | ||
{ | ||
switch (s[i]) | ||
{ | ||
case 'G': | ||
ans[i] = 'C'; | ||
break; | ||
case 'C': | ||
ans[i] = 'G'; | ||
break; | ||
case 'T': | ||
ans[i] = 'A'; | ||
break; | ||
case 'A': | ||
ans[i] = 'U'; | ||
break; | ||
} | ||
} | ||
|
||
return ans; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef __RNA_TRANSCRIPTION__H | ||
#define __RNA_TRANSCRIPTION__H | ||
|
||
/* to_rna: compiles a DNA strand in its RNA complement */ | ||
char * to_rna(const char s[]); | ||
|
||
#endif |