Write a program to transcribe DNA to RNA c++

User Generated

Gzjuvgr12500

Programming

Description

 Nesting: L. 2 Application, Code Writing (Biology). Write a program to
transcribe DNA to RNA.  Have the user enter a string called dna, then loop over
it and transcribe each character as follows: A->U, T->A, C->G, G->C. Make sure it is formatted correctly [5]. Example interaction is shown below.
> ACGTGA  // input
< UGCACU  // output
note: I have written a program that will transcribe one into the other, but I can't figure out how to get it to transcribe a string input. This is what I have come up with:

#include <iostream>
using namespace std;

int main() 
{
  cout << "> ";
  cin  >> dna;
  int a = dna;
  cout << "< ";
    if (a == 'A') cout << 'U';
    else if (a == 'C') cout << 'G';
    else if (a == 'G') cout << 'C';
    else if (a == 'T') cout << 'A';
    cout << " "<< endl;
    return 0;
}

I'm pretty sure the program has to include a for loop, but I'm uncertain as to how to initialize it and what the condition would be.



User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
Very useful material for studying!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags