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

13.19 Arrays Ex3 Suppose we are interested in studying a DNA sequence which cons

ID: 3722987 • Letter: 1

Question

13.19 Arrays Ex3 Suppose we are interested in studying a DNA sequence which consists of four bases A C, G, and T. For example TGCGTGCTACCACATCATGCAGTTTTCAAAGAAGAAAGCCTCACCACAAA Your goal is to compute the occurrence (expressed as a percentage) of each base and output it in the following format (including the header) Base Statistics A: 26.4 C: 44.1 G: 34.8 T: 13.6 Constraints . The DNA sequence can be from 1 to 50 characters long. . In order to output floating point numbers with only one decimal digit, you may use %.1lf . You must read the DNA sequence input from the user Example 1 LAB ACTY 13.19.1: Arrays-Ex 0 16 dna.c Load default template... #include 3 int main) Type your code here, 7return a

Explanation / Answer

written the below program, takes input as DNA sequence and counts only A,C,G & T.

Please provide the input DNA sequence in captial letters. (small letters checking is not added)

Max input is 50 characters and output is printed for one digit after decimal point.

it reads the DNA sequence from user.

#include <stdio.h>

int main()
{
char DNASeq[50]=" ";
int DNAcount;
int BaseA=0,BaseC=0,BaseG=0,BaseT=0;
float Apercent=0.00, Cpercent=0.00, Gpercent=0.00, Tpercent=0.00;
printf("Input DNA sequence:");
scanf("%s",DNASeq);

for(int i=0;DNASeq[i]!='';i++)
{
DNAcount = DNAcount + 1;
  
switch(DNASeq[i])
{
case 'A':
BaseA = BaseA + 1;
break;
case 'C':
BaseC = BaseC + 1;
break;
case 'G':
BaseG = BaseG + 1;
break;
case 'T':
BaseT = BaseT + 1;
break;
}
}
  
Apercent = (float)BaseA/DNAcount;
Cpercent = (float)BaseC/DNAcount;
Gpercent = (float)BaseG/DNAcount;
Tpercent = (float)BaseT/DNAcount;
  
  
printf("Base statistics: ");
  
printf(" A: %.1f",Apercent*100);
printf(" C: %.1f",Cpercent*100);
printf(" G: %.1f",Gpercent*100);
printf(" T: %.1f",Tpercent*100);

return 0;
}

Tested above program for 3 - 4 DNA sequence, results are expected.

please find below one input output results

input


Input DNA sequence:AAAACGGTTTTT   
Base statistics:

A: 33.3   
C: 8.3
G: 16.7   
T: 41.7

Could you please execute and verify

Thanks & regards

#include <stdio.h>

int main()
{
char DNASeq[50]=" ";
int DNAcount;
int BaseA=0,BaseC=0,BaseG=0,BaseT=0;
float Apercent=0.00, Cpercent=0.00, Gpercent=0.00, Tpercent=0.00;
printf("Input DNA sequence:");
scanf("%s",DNASeq);

for(int i=0;DNASeq[i]!='';i++)
{
DNAcount = DNAcount + 1;
  
switch(DNASeq[i])
{
case 'A':
BaseA = BaseA + 1;
break;
case 'C':
BaseC = BaseC + 1;
break;
case 'G':
BaseG = BaseG + 1;
break;
case 'T':
BaseT = BaseT + 1;
break;
}
}
  
Apercent = (float)BaseA/DNAcount;
Cpercent = (float)BaseC/DNAcount;
Gpercent = (float)BaseG/DNAcount;
Tpercent = (float)BaseT/DNAcount;
  
  
printf("Base statistics: ");
  
printf(" A: %.1f",Apercent*100);
printf(" C: %.1f",Cpercent*100);
printf(" G: %.1f",Gpercent*100);
printf(" T: %.1f",Tpercent*100);

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