Question

Summary given 2 DNA strands of equal length, compare the bas 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 **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 # o differences f the strands are identical the # of differences reported should be 0. Dont forget to #include <string> so you have access to the string functionality in Ct+ [ Hint this is not as hard as it looks, Input the 2 DNA strands, output the first, then loop over the strings like you have done in the other exercises. But instead of comparing the ith character to a known letter such as C or G) compare to the ith character in the other string Count and output as you loop, then after the loop output the 2nd DNA strand and the # of differences.] PROGRAMMING INSTRUCTIONS Zyante contains a complete C++ programming environment, so you are free to work here. Zyante provides 2 modes: Develop and Submit In Develop mode, you supply the input values in the text field provided, then click Run program to run your program and see the


in c++ language please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
using namespace std;

int main() {
// declaring variables
string a, b;
int count = 0;
  
// taking user input
cout << "Enter DNA 1: ";
cin >> a;
cout << "Enter DNA 2: ";
cin >> b;
  
// printing first strand
cout << endl << a << endl;
  
// looping through each character
for(int i=0;i<a.length();i++)
{
// checking if they are equal
if(a[i]==b[i])
cout << " ";
// if not, increasing count by 1 and printing X
else
{
count++;
cout << "X";
}
}
  
// printing second strand
cout << endl << b << endl;
cout << "**Differences: " << count << endl;
}

SAMPLE OUTPUT

Enter DNA 1:  CCATGGTC
Enter DNA 2:  CCAGTGAC

CCATGGTC
   XX X 
CCAGTGAC
**Differences: 3
Add a comment
Know the answer?
Add Answer to:
in c++ language please Summary given 2 DNA strands of equal length, compare the bas Given...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What’s the C++ code to this? So that my output is: CCTAGAATG | | X |...

    What’s the C++ code to this? So that my output is: CCTAGAATG | | X | | X | | GGACCTAAC Validity: 77.7778% Stability: 57.1429% Part #02 The goal is to write a complete C++ program that inputs 2 strings from the keyboard, where each string denotes a DNA strand such as CCTAGAATG. Assume the 2 strings are the same length. The program will then CS 109: htp:/bwww.csic.edu i109 Page I of 3 line up the two strands to see...

  • using c language String Challenge Have the function StringChallenge(str) read str which will contain two strings...

    using c language String Challenge Have the function StringChallenge(str) read str which will contain two strings separated by a space. The first string will consist of the following sets of characters: +, *, $, and {N} which is optional. The plus (+) character represents a single alphabetic character, the ($) character represents a number between 1-9, and the asterisk (*) represents a sequence of the same character of length 3 unless it is followed by {N} which represents how many...

  • c programming

    Write a c program that reads a string with a maximum length of 30 from the keyboard[1]. The program should then copy the characters from that input string into a second character array (in order of input). However, only if a character is a vowel (a, e, i, o, u) should it be copied into the second array. Once copied, the program should output the values stored in the second array (in order of input). The program should then count...

  • Consider the following C++ program. It reads a sequence of strings from the user and uses...

    Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13 +...

  • Instructions: Consider the following C++ program. It reads a sequence of strings from the user and...

    Instructions: Consider the following C++ program. It reads a sequence of strings from the user and uses "rot13" encryption to generate output strings. Rot13 is an example of the "Caesar cipher" developed 2000 years ago by the Romans. Each letter is rotated 13 places forward to encrypt or decrypt a message. For more information see the rot13 wiki page. #include <iostream> #include <string> using namespace std; char rot13(char ch) { if ((ch >= 'a') && (ch <= 'z')) return char((13...

  • Please, please help! (Programming Assignment: fork gymnastics) Write a C/C++ program (call it string-invert) that takes...

    Please, please help! (Programming Assignment: fork gymnastics) Write a C/C++ program (call it string-invert) that takes a string argument from the command line and outputs the string in reversed order You have two constraints: Constraint 1: Each process can output at most one character. If you want to output more than a single character, you must fork off one or more processes in order to do that, and each of the forked processes in turn outputs a single character t...

  • JAVA LANGUAGE For this lab you are required to fulfill all requirements exactly as described in...

    JAVA LANGUAGE For this lab you are required to fulfill all requirements exactly as described in this provided document, no less, no more. Question: Today you are to write a Java program that will prompt for and read 2 words of equal length entered by the user, and create a new word which contains the last letter of the 1st word, the last letter of the 2nd word, followed by the second to last character of the 1st word, followed...

  • Summary In this lab, you add a loop and the statements that make up the loop...

    Summary In this lab, you add a loop and the statements that make up the loop body to a Java program that is provided. When completed, the program should calculate two totals: the number of left-handed people and the number of right-handed people in your class. Your loop should execute until the user enters the character X instead of L for left-handed or R for right-handed. The inputs for this program are as follows: R, R, R, L, L, L,...

  • In this assignment, you will implement a deterministic finite automata (DFA) using C++ programming language to...

    In this assignment, you will implement a deterministic finite automata (DFA) using C++ programming language to extract all matching patterns (substrings) from a given input DNA sequence string. The alphabet for generating DNA sequences is {A, T, G, C}. Write a regular expression that represents all DNA strings that contains at least two ‘A’s. Note: assume empty string is not a valid string. Design a deterministic finite automaton to recognize the regular expression. Write a program which asks the user...

  • Today you are to write a Java program that will prompt for and read 2 words...

    Today you are to write a Java program that will prompt for and read 2 words of equal length entered by the user, and create a new word which contains the last letter of the 1st word, the last letter of the 2nd word, followed by the second to last character of the 1st word, followed by the second to last character of the 2nd word and so on. Be sure to use the same format and wording as in...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT