-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDNA TO RNA.CPP
More file actions
37 lines (29 loc) · 827 Bytes
/
DNA TO RNA.CPP
File metadata and controls
37 lines (29 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
#include<string>
using namespace std;
string dnatorna(string dna) {
string rna = "";
for (char c : dna) // Iterate through each character in the DNA string
{
if (c == 'T') {
rna += 'U'; // Replace Thymine with Uracil
} else {
rna += c; // Keep other characters the same
}
}
return rna;
}
int main() {
string dna;
cout << "Enter a DNA sequence(Only A T G C ): ";
cin >> dna; // Input the DNA sequence from the user
string rna = dnatorna(dna); // Convert DNA to RNA
cout << "RNA sequence: " << rna << endl; // Output the RNA sequence
return 0;
}
/*best soluATION
std::string DNAtoRNA(std::string dna){
std::replace(dna.begin(), dna.end(), 'T', 'U');
return dna;
}
*/