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

s e we are interested studying a DNA which consists four bases: A,C, of suld seq

ID: 3849844 • Letter: S

Question

s e we are interested studying a DNA which consists four bases: A,C, of suld sequence r. in (a) Create a random DNA string of length n. Hint remember to terminate the string with (b) mine how many times A occurs in the dna string. Dete (c) Remove the hard coding to determine how many times the character base occurs in the dna string. (d) Print the statistics as follows: Sequence 50 Base Statistics AGTTTTCAAAGAAGAANGCCTCACCACAAA A: 26.4 C: 44.1 34.8 T: 13.6 9. Write a program that creates a random dna string and then (a) Blanks out everything but all the A characters: dna TGcGTGCTACCACATCAT dotstr A. .A.A..A. A. (b) Remove the hard coding so that any dna character can be easily blanked out (c) Display all blanked out strings 10. (a) Write a program which stores a sentence as a string and computes how many letters in the string are capital letters. (b) Repeat for lower case. (c) Write a program that stores a string and converts all characters to upper case. (d) Write a corresponding transform to lowercase. 11. (a) Write a program that stores a sentence and then creates an array containing the index where each word starts. For example: str: "The Cat in the Hat index: 10 4 8 11 151 You can assume that the array starts with a letter (and not a space). (b) Write a program that takes in a string and capitalizes the first letter of each word.

Explanation / Answer

12.

a)

output:

sh-4.2$ gcc -o main *.c                                                                                                                                                         

sh-4.2$ main                                                                                                                                                                    

Enter a positive integer: 2                                                                                                                                                     

2 is a prime number.sh-4.2$ gcc -o main *.c                                                                                                                                     

sh-4.2$ main                                                                                                                                                                    

Enter a positive integer: 7                                                                                                                                                     

7 is a prime number.sh-4.2$ main                                                                                                                                                

Enter a positive integer: 35       

35 is not a prime number

b)

#include<stdio.h>
int main(){
int numbr,k,remark;
printf(" The prime numbers between 1 and 1000 : ");
for(numbr=2;numbr<=1000;++numbr)
{
remark=0;
for(k=2;k<=numbr/2;k++){
if((numbr % k) == 0){
remark++;
break;
}
}
if(remark==0)
printf(" %d, ",numbr);
}
return 0;
}

output:

sh-4.2$ gcc -o main *.c                                                                                                                                                         

sh-4.2$ main                                                                                                                                                                    

The prime numbers between 1 and 1000 :                                                                                                                                         

2,  3,  5,  7,  11,  13,  17,  19,  23,  29,  31,  37,  41,  43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,  103,  107,  109,  113,  127,  131,  137,  139,  

149,  151,  157,  163,  167,  173,  179,  181,  191,  193,  197,  199,  211,  223,  227,  229,  233,  239,  241,  251,  257,  263,  269,  271,  277,  281,  283,  293,  307,  31

1,  313,  317,  331,  337,  347,  349,  353,  359,  367,  373,  379,  383,  389,  397,  401,  409,  419,  421,  431,  433,  439,  443,  449,  457,  461,  463,  467,  479,  487,

  491,  499,  503,  509,  521,  523,  541,  547,  557,  563,  569,  571,  577,  587,  593,  599,  601,  607,  613,  617,  619,  631,  641,  643,  647,  653,  659,  661,  673,  

677,  683,  691,  701,  709,  719,  727,  733,  739,  743,  751,  757,  761,  769,  773,  787,  797,  809,  811,  821,  823,  827,  829,  839,  853,  857,  859,  863,  877,  88