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

Given two DNA strands of equal length, write a complete C++ program to compare t

ID: 670421 • Letter: G

Question

Given two DNA strands of equal length, write a complete C++ program to compare the corresponding bases, and report mismatches. For example, suppose the input to your program are the following two DNA strands: CCATGGTC CCAGTGAC then your program should produce the following output: CCATGGTC XX X CCAGTGAC Differences: 3 In other words, your program should output the first strand, then on the next line output a space if the corresponding bases are the same and an 'X' if not, followed by the second strand, followed by a summary of the # of differences. If the strands are identical, the # of differences reported should be 0. Don't forget to #include

Explanation / Answer

#include<iostream>
#include<string.h> // for using strlen()

#include<string>
using namespace std;

int main()

{

char s1[10]; // assuming length of string is 10

char s2[10];

int i;

cin>>s1>>s2;

cout<<s1<<endl;
int len=strlen(s1);
for(i=0;i<len;i++)

{
if(s1[i]==s2[i])

cout<<" ";

else

cout<<'x';

}

cout<<endl<<s2;

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