Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Writing Functions 1) Write a function i sValidDNAchar that returns true if a

ID: 3762163 • Letter: C

Question

C++ Writing Functions

1) Write a function isValidDNAchar that returns true if a char argument is one of 'a', 'c', 'g', 't'. Otherwise the function returns false.

2) Then using that function, write a function isValidDNAstring that returns true if a string is only made up of valid DNA characters (a, c, g, t). If any other character exists in the string false is returned. You will want to call isValidDNAchar from within this function.

3) Then write a function ,transcribe, that changes DNA into RNA. Taking a string of DNA (ex. ttagcatctgg) , and couting the same thing except 't' is changed to a 'u' (ex. uuagcaucugg)

Explanation / Answer

#include<iostream>

using namespace std;

bool isValidDNAChar(char c){

if( c == 'a' || c == 'c' || c == 'g' || c == 't')

return true;

else

return false;

}

bool isValidDNAString(string s){

for(int i = 0; i < s.length(); i++)

if( !isValidDNAChar(s[i]))

return false;

return true;

}

int main(){

cout<<isValidDNAString("tgaaacccfcc");

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote